@Override public String toString() { StringBuilder sb = new StringBuilder(); if (columns == null) { sb.append('[').append(columnCount).append(" columns]"); } else { for (ColumnDefinitions.Definition column : columns) { sb.append('[').append(column.getName()); sb.append(" (").append(column.getType()).append(")]"); } } if (pagingState != null) sb.append(" (to be continued)"); return sb.toString(); } }
protected void updateParameterMetaData(CassandraCqlStatement cql, boolean force) throws SQLException { if (force || !Objects.equal(this.cqlStmt.getCql(), cql.getCql())) { this.cqlStmt = cql; PreparedStatement preparedStmt = getInnerPreparedStatement(cql.getCql()); parameterMetaData.clear(); for (ColumnDefinitions.Definition def : preparedStmt.getVariables().asList()) { parameterMetaData.addParameterDefinition(new CassandraColumnDefinition( def.getKeyspace(), def.getTable(), def.getName(), def.getName(), def.getType().toString(), false, false)); } } }
@Override public Token getPartitionKeyToken() { int i = 0; for (ColumnDefinitions.Definition column : metadata) { if (TOKEN_COLUMN_NAME.matcher(column.getName()).matches()) return getToken(i); i++; } throw new IllegalStateException("Found no column named 'token(...)'. If the column is aliased, use getToken(String)."); }
@Override public Token getPartitionKeyToken() { int i = 0; for (ColumnDefinitions.Definition column : metadata) { if (TOKEN_COLUMN_NAME.matcher(column.getName()).matches()) return getToken(i); i++; } throw new IllegalStateException("Found no column named 'token(...)'. If the column is aliased, use getToken(String)."); }
private CqlColumnListImpl<C> getAstyanaxColumnList(Row row) { List<CqlColumnImpl<C>> list = new ArrayList<CqlColumnImpl<C>>(); List<Definition> colDefs = row.getColumnDefinitions().asList(); int index = 0; for (Definition colDef : colDefs) { C columnName = (C) colDef.getName(); list.add(new CqlColumnImpl<C>(columnName, row, index, colDef)); index++; } return new CqlColumnListImpl<C>(list); } }
/** * Column family exists verify. * @param resultSet */ private void verifyRowType(ResultSet resultSet, Class<?> class1, Session session) { Map<String, String> mapNameType = new HashMap<String, String>(); for (Definition column : resultSet.getColumnDefinitions()) { mapNameType .put(column.getName(), column.getType().getName().name()); } ClassInformation classInformation = ClassInformations.INSTACE.getClass(class1); verifyRow(classInformation, session, mapNameType); }
@Override public Object getObject(Map<String, Definition> mapDefinition, FieldInformation field, Row row) { Definition column = mapDefinition.get(field.getName().toLowerCase()); return RelationShipJavaCassandra.INSTANCE.getObject(row, column .getType().getName(), column.getName()); }
protected Map<String, Object> toMap(Row row) { Map<String, Object> map = null; if (row != null) { ColumnDefinitions columns = row.getColumnDefinitions(); map = new HashMap<String, Object>(columns.size()); for (Definition columnDefinition : columns.asList()) { map.put(columnDefinition.getName(), columnToObject(row, columnDefinition)); } } return map; }
@Override public String toString() { ToStringHelper toStringHelper = MoreObjects.toStringHelper(this); for (Definition definition : getRow().getColumnDefinitions().asList()) { toStringHelper.add(definition.getName(), toString(definition.getName(), definition.getType())); } return toStringHelper.toString(); }
private static CassandraBackendEntry row2Entry(HugeType type, Row row) { CassandraBackendEntry entry = new CassandraBackendEntry(type); List<Definition> cols = row.getColumnDefinitions().asList(); for (Definition col : cols) { String name = col.getName(); Object value = row.getObject(name); entry.column(CassandraTable.parseKey(name), value); } return entry; }
private Map<String, Definition> createMapDefinition(ColumnDefinitions columnDefinitions) { Map<String, Definition> map = new HashMap<String, ColumnDefinitions.Definition>(); for (Definition column : columnDefinitions) { map.put(column.getName(), column); } return map; }
@Override public Token getPartitionKeyToken() { int i = 0; for (ColumnDefinitions.Definition column : metadata) { if (TOKEN_COLUMN_NAME.matcher(column.getName()).matches()) return getToken(i); i++; } throw new IllegalStateException("Found no column named 'token(...)'. If the column is aliased, use getToken(String)."); }
while (columnDefIter.hasNext()) { Definition columnDef = columnDefIter.next(); final String columnName = columnDef.getName(); // column name
columnDef.getName(), null, null));
/** * Iterate and return. * * @param rSet * the r set * @return the list */ private List iterateAndReturn(ResultSet rSet) { Iterator<Row> rowIter = rSet.iterator(); List results = new ArrayList(); while (rowIter.hasNext()) { Row row = rowIter.next(); ColumnDefinitions columnDefs = row.getColumnDefinitions(); Iterator<Definition> columnDefIter = columnDefs.iterator(); Map rowData = new HashMap(); while (columnDefIter.hasNext()) { Definition columnDef = columnDefIter.next(); rowData.put(columnDef.getName(), DSClientUtilities.assign(row, null, null, columnDef.getType().getName(), null, columnDef.getName(), null, null)); } results.add(rowData); } return results; }
public RawNumericMetric map(Row row) { RawNumericMetric metricRow = new RawNumericMetric(row.getString(0), row.getString(1), row.getDate(2).getTime(), row.getInt(3)); ColumnDefinitions columeDef = row.getColumnDefinitions(); List<Definition> columeDefList = columeDef.asList(); Map<String, String> tagMap = new HashMap<String, String>(); for(Definition def: columeDefList){ if(def.getName().startsWith("tag_")){ tagMap.put(def.getName(), row.getString(def.getName())); } } if(tagMap.size()>0){ metricRow.setTagMap(tagMap); } return metricRow; }
private static CassandraBackendEntry row2Entry(HugeType type, Row row) { CassandraBackendEntry entry = new CassandraBackendEntry(type); List<Definition> cols = row.getColumnDefinitions().asList(); for (Definition col : cols) { String name = col.getName(); Object value = row.getObject(name); entry.column(CassandraTable.parseKey(name), value); } return entry; }
@Override public Token getPartitionKeyToken() { int i = 0; for (ColumnDefinitions.Definition column : metadata) { if (TOKEN_COLUMN_NAME.matcher(column.getName()).matches()) return getToken(i); i++; } throw new IllegalStateException( "Found no column named 'token(...)'. If the column is aliased, use getToken(String)."); }