protected int appendParameters(BoundStatement statement, StringBuilder buffer, int remaining) { if (remaining == 0) return 0; ColumnDefinitions metadata = statement.preparedStatement().getVariables(); int numberOfParameters = metadata.size(); if (numberOfParameters > 0) { List<ColumnDefinitions.Definition> definitions = metadata.asList(); int numberOfLoggedParameters; if (remaining == -1) { numberOfLoggedParameters = numberOfParameters; } else { numberOfLoggedParameters = Math.min(remaining, numberOfParameters); remaining -= numberOfLoggedParameters; } for (int i = 0; i < numberOfLoggedParameters; i++) { if (buffer.length() == 0) buffer.append(" ["); else buffer.append(", "); String value = statement.isSet(i) ? parameterValueAsString(definitions.get(i), statement.wrapper.values[i]) : "<UNSET>"; buffer.append(String.format("%s:%s", metadata.getName(i), value)); } if (numberOfLoggedParameters < numberOfParameters) { buffer.append(FURTHER_PARAMS_OMITTED); } } return remaining; }
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 protected void head(ColumnDefinitions columnDefinitions, PrintStream out) { definitions = columnDefinitions.asList().toArray(new ColumnDefinitions.Definition[]{}); // Json Columns if (commandLine.hasOption("j")) { String cols = commandLine.getOptionValue("j"); String[] arCols = cols.split(","); jsonColumns.addAll(Arrays.asList(arCols)); } }
@VisibleForTesting Map<String, DataType> getColumnDefinitions(Row row) { return row.getColumnDefinitions() .asList() .stream() .collect( Collectors.toMap( Definition::getName, Definition::getType, (d1, d2) -> { return d1; })); }
@Override public List<Object> convert(Row row) { ColumnDefinitions cols = row.getColumnDefinitions(); return cols.asList().stream() // .map(Definition::getName).map(name -> row.isNull(name) ? null : row.getObject(name)) // .collect(Collectors.toList()); } }
@Override public Map<String, Object> convert(Row row) { ColumnDefinitions cols = row.getColumnDefinitions(); Map<String, Object> map = new HashMap<>(cols.size()); cols.asList().stream().map(Definition::getName) .forEach(name -> map.put(name, row.isNull(name) ? null : row.getObject(name))); return map; } }
public CqlColumnImpl(C colName, Row row, int index) { this.columnName = colName; this.row = row; this.index = index; Definition colDefinition = row.getColumnDefinitions().asList().get(index); isBlob = colDefinition.getType() == DataType.blob(); }
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; }
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); } }
@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(); }
public String getColumnName(int column) throws SQLException { //checkIndex(column); try{ if(currentRow!=null){ return currentRow.getColumnDefinitions().getName(column-1); } return driverResultSet.getColumnDefinitions().asList().get(column-1).getName(); }catch(Exception e){ return ""; } }
public String getColumnName(int column) throws SQLException { //checkIndex(column); if(currentRow!=null){ return currentRow.getColumnDefinitions().getName(column-1); } return driverResultSet.getColumnDefinitions().asList().get(column-1).getName(); }
@Override public Map<String, Object> convert(Row row) { if (row == null) { return null; } ColumnDefinitions cols = row.getColumnDefinitions(); Map<String, Object> map = new HashMap<String, Object>(cols.size()); for (Definition def : cols.asList()) { String name = def.getName(); map.put(name, row.isNull(name) ? null : row.getObject(name)); } return map; } }
public int getColumnType(int column) throws SQLException { DataType type = null; if(currentRow!=null){ type = currentRow.getColumnDefinitions().getType(column-1); }else{ type = driverResultSet.getColumnDefinitions().asList().get(column-1).getType(); } return TypesMap.getTypeForComparator(type.toString()).getJdbcType(); }
public int getColumnType(int column) throws SQLException { DataType type = null; if(currentRow!=null){ type = currentRow.getColumnDefinitions().getType(column-1); }else{ type = driverResultSet.getColumnDefinitions().asList().get(column-1).getType(); } return TypesMap.getTypeForComparator(type.toString()).getJdbcType(); }
public String getColumnClassName(int column) throws SQLException { if(currentRow!=null){ return DataTypeEnum.fromCqlTypeName(currentRow.getColumnDefinitions().getType(column-1).getName()).asJavaClass().getCanonicalName(); } return DataTypeEnum.fromCqlTypeName(driverResultSet.getColumnDefinitions().asList().get(column-1).getType().getName()).asJavaClass().getCanonicalName(); }
public String getColumnClassName(int column) throws SQLException {/* checkIndex(column); return values.get(column - 1).getValueType().getType().getName();*/ if(currentRow!=null){ return currentRow.getColumnDefinitions().getType(column-1).getName().toString(); } return driverResultSet.getColumnDefinitions().asList().get(column-1).getType().getName().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; }
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)); } } }