return row.getTime(i); } else if (dataType.isCollection()) {
if (dataType.isCollection()) { List<DataType> typeArguments = dataType.getTypeArguments(); if (typeArguments == null || typeArguments.size() == 0) {
static boolean isBuildInType(DataType dataType) { if (dataType.isCollection()) { for (DataType type : dataType.getTypeArguments()) { if (!isBuildInType(type)) { return false; } } return true; } else { return DataType.allPrimitiveTypes().contains(dataType) || (TupleType.class.isAssignableFrom(dataType.getClass())); } }
if ((!dataType.isCollection()) && (!counterColumns.contains(colNameEntry))) { queryExpression.append(" " + colNameEntry + " = :" + colNameEntry); continue; if ((dataType.isCollection()) && (!dataType.isFrozen())) { if (collectionMutationStyle == UpsertExecutionContext.CollectionMutationStyle.REMOVE_FROM_EXISTING_COLLECTION) { queryExpression.append(" " + colNameEntry + " = " + colNameEntry + " - :" + colNameEntry); if ((dataType.isCollection()) && (dataType.isFrozen())) { queryExpression.append(" " + colNameEntry + " = :" + colNameEntry);
if ((!dataType.isCollection()) && (!counterColumns.contains(colNameEntry))) { queryExpression.append(" " + colNameEntry + " = :" + colNameEntry); continue; if ((dataType.isCollection()) && (!dataType.isFrozen())) { if (collectionMutationStyle == UpsertExecutionContext.CollectionMutationStyle.REMOVE_FROM_EXISTING_COLLECTION) { queryExpression.append(" " + colNameEntry + " = " + colNameEntry + " - :" + colNameEntry); if ((dataType.isCollection()) && (dataType.isFrozen())) { queryExpression.append(" " + colNameEntry + " = :" + colNameEntry);
static boolean isBuildInType(DataType dataType) { if (dataType.isCollection()) { for (DataType type : dataType.getTypeArguments()) { if (!isBuildInType(type)) { return false; } } return true; } else { return DataType.allPrimitiveTypes().contains(dataType); } }
public List<?> getList(int index) throws SQLException { checkIndex(index); if(currentRow.getColumnDefinitions().getType(index-1).isCollection()){ try { return Lists.newArrayList(currentRow.getList(index - 1,Class.forName(currentRow.getColumnDefinitions().getType(index-1).getTypeArguments().get(0).getClass().getCanonicalName()))); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } // TODO: a remplacer par une vraie verification des types de collections } return currentRow.getList(index - 1,String.class); }
public List<?> getList(String name) throws SQLException { checkName(name); // return currentRow.getList(name,String.class); // TODO: a remplacer par une vraie verification des types de collections if(currentRow.getColumnDefinitions().getType(name).isCollection()){ try { return Lists.newArrayList(currentRow.getList(name,Class.forName(currentRow.getColumnDefinitions().getType(name).getTypeArguments().get(0).getClass().getCanonicalName()))); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } // TODO: a remplacer par une vraie verification des types de collections } return currentRow.getList(name,String.class); }
public ComparatorType getComparatorType() { if (cType != null) { return cType; } // Lazy init DataType type = row.getColumnDefinitions().getType(index); if (type.isCollection()) { throw new RuntimeException("This operation does not work for collection objects"); } String typeString = (type.getName().name()).toUpperCase(); cType = CqlTypeMapping.getComparatorFromCqlType(typeString); return cType; } }
public String getString(int index) throws SQLException { checkIndex(index); try{ if(currentRow.getColumnDefinitions().getType(index-1).isCollection()){ return getObject(index).toString(); } return currentRow.getString(index-1); }catch(Exception e){ return getObject(index).toString(); } }
public String getString(String name) throws SQLException { checkName(name); try{ if(currentRow.getColumnDefinitions().getType(name).isCollection()){ return getObject(name).toString(); } return currentRow.getString(name); }catch(Exception e){ return getObject(name).toString(); } }
public String getString(String name) throws SQLException { checkName(name); try{ if(currentRow.getColumnDefinitions().getType(name).isCollection()){ return getObject(name).toString(); } return currentRow.getString(name); }catch(Exception e){ return getObject(name).toString(); } }
if (!type.isCollection()) { validatorClassName = MAP_JAVA_TYPE_TO_ABSTRACT_TYPE.get(type.asJavaClass()).getClass() .getName();
public String getString(int index) throws SQLException { checkIndex(index); try{ if(currentRow.getColumnDefinitions().getType(index-1).isCollection()){ return getObject(index).toString(); } return currentRow.getString(index-1); }catch(Exception e){ return getObject(index).toString(); } }
private void registerNonPKColumnDefinitions(final TableMetadata tableMetadata) { List<ColumnMetadata> colInfoForTable = tableMetadata.getColumns(); for (ColumnMetadata aColumnDefinition : colInfoForTable) { if (aColumnDefinition.getType().isCollection()) { collectionColumns.add(aColumnDefinition.getName()); } if (!pkColumnNames.contains(aColumnDefinition.getName())) { columnDefinitions.put(aColumnDefinition.getName(), aColumnDefinition.getType()); regularColumns.add(aColumnDefinition.getName()); } parseForSpecialDataType(aColumnDefinition); } }
private void registerNonPKColumnDefinitions(final TableMetadata tableMetadata) { List<ColumnMetadata> colInfoForTable = tableMetadata.getColumns(); for (ColumnMetadata aColumnDefinition : colInfoForTable) { if (aColumnDefinition.getType().isCollection()) { collectionColumns.add(aColumnDefinition.getName()); } if (!pkColumnNames.contains(aColumnDefinition.getName())) { columnDefinitions.put(aColumnDefinition.getName(), aColumnDefinition.getType()); regularColumns.add(aColumnDefinition.getName()); } parseForSpecialDataType(aColumnDefinition); } }
public List<?> getList(int index) throws SQLException { checkIndex(index); if(currentRow.getColumnDefinitions().getType(index-1).isCollection()){ try { return Lists.newArrayList(currentRow.getList(index - 1,Class.forName(DataTypeEnum.fromCqlTypeName(currentRow.getColumnDefinitions().getType(index-1).getTypeArguments().get(0).getName()).asJavaClass().getCanonicalName()))); } catch (ClassNotFoundException e) { logger.warn("Error while executing getList()", e); } } return currentRow.getList(index - 1,String.class); }
public List<?> getList(String name) throws SQLException { checkName(name); if(currentRow.getColumnDefinitions().getType(name).isCollection()){ try { return Lists.newArrayList(currentRow.getList(name, Class.forName(DataTypeEnum.fromCqlTypeName(currentRow.getColumnDefinitions().getType(name).getTypeArguments().get(0).getName()).asJavaClass().getCanonicalName()))); } catch (ClassNotFoundException e) { logger.warn("Error while executing getList()", e); } } return currentRow.getList(name,String.class); }
@Test public void testActivateForSchemaDetection() throws Exception { assertEquals(12, userUpsertOperator.getPreparedStatementTypes().size()); assertEquals( " UPDATE unittests.users SET currentaddress = :currentaddress, emails = emails - :emails, " + "todo = todo - :todo, top_scores = top_scores - :top_scores, siblings = :siblings, " + "previousnames = :previousnames, username = :username WHERE userid = :userid", userUpsertOperator.getPreparedStatementTypes().get(101001100L).getQueryString()); assertEquals(8, userUpsertOperator.getColumnDefinitions().size()); assertEquals(true, userUpsertOperator.getColumnDefinitions().get("currentaddress").isFrozen()); assertEquals(false, userUpsertOperator.getColumnDefinitions().get("currentaddress").isCollection()); assertEquals(true, userUpsertOperator.getColumnDefinitions().get("top_scores").isCollection()); assertEquals(true, userUpsertOperator.getColumnDefinitions().get("username").isFrozen()); assertEquals(false, userUpsertOperator.getColumnDefinitions().get("username").isCollection()); }
/** * Read data from Column at the given {@code index}. * * @param columnIndex {@link Integer#TYPE index} of the Column. * @return the value of the Column in at index in the Row, or {@literal null} if the Column contains no value. */ @Nullable public Object get(int columnIndex) { if (row.isNull(columnIndex)) { return null; } DataType type = columns.getType(columnIndex); if (type.isCollection()) { return getCollection(columnIndex, type); } if (Name.TUPLE.equals(type.getName())) { return row.getTupleValue(columnIndex); } if (Name.UDT.equals(type.getName())) { return row.getUDTValue(columnIndex); } return row.getObject(columnIndex); }