com.datastax.driver.core.Row.getColumnDefinitions()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中com.datastax.driver.core.Row.getColumnDefinitions方法的一些代码示例,展示了Row.getColumnDefinitions的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Row.getColumnDefinitions方法的具体详情如下:
包路径:com.datastax.driver.core.Row
类名称:Row
方法名:getColumnDefinitions

Row.getColumnDefinitions介绍

[英]Returns the columns contained in this Row.
[中]返回此行中包含的列。

代码示例

代码示例来源:origin: brianfrankcooper/YCSB

tuple = new HashMap<String, ByteIterator>();
ColumnDefinitions cd = row.getColumnDefinitions();

代码示例来源:origin: brianfrankcooper/YCSB

ColumnDefinitions cd = row.getColumnDefinitions();

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

private static void formatMissingOrNullColumn(Row peerRow, String columnName, StringBuilder sb) {
 if (!peerRow.getColumnDefinitions().contains(columnName))
  sb.append(", missing ").append(columnName);
 else if (peerRow.isNull(columnName)) sb.append(", ").append(columnName).append("=null");
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

private static boolean isNullOrAbsent(Row row, String name) {
 return row.getColumnDefinitions().getIndexOf(name) < 0 || row.isNull(name);
}

代码示例来源:origin: Impetus/Kundera

void populateObjectFromRow(EntityMetadata metadata, MetamodelImpl metaModel, EntityType entityType, List results,
  Map<String, Object> relationalValues, Object entity, Row row) {
  ColumnDefinitions columnDefs = row.getColumnDefinitions();
  Iterator<Definition> columnDefIter = columnDefs.iterator();
  entity = iteratorColumns(metadata, metaModel, entityType, relationalValues, entity, row, columnDefIter);
  if (entity != null && entity.getClass().isAssignableFrom(metadata.getEntityClazz())) {
    Object rowKey = PropertyAccessorHelper.getId(entity, metadata);
    // populate secondary tables data if there is any.
    populateSecondaryTableData(rowKey, entity, metaModel, metadata);
    if (!relationalValues.isEmpty()) {
      results.add(new EnhanceEntity(entity, rowKey, relationalValues));
    } else {
      results.add(entity);
    }
  } else if (entity != null) {
    results.add(entity);
  }
}

代码示例来源:origin: Impetus/Kundera

@Override
public <E> List<E> getColumnsById(String schemaName, String tableName, String pKeyColumnName, String columnName,
  Object pKeyColumnValue, Class columnJavaType) {
  // select columnName from tableName where pKeyColumnName =
  // pKeyColumnValue
  List results = new ArrayList();
  CQLTranslator translator = new CQLTranslator();
  String selectQuery = translator.SELECT_QUERY;
  selectQuery = StringUtils.replace(selectQuery, CQLTranslator.COLUMN_FAMILY,
    translator.ensureCase(new StringBuilder(), tableName, false).toString());
  selectQuery = StringUtils.replace(selectQuery, CQLTranslator.COLUMNS,
    translator.ensureCase(new StringBuilder(), columnName, false).toString());
  StringBuilder selectQueryBuilder = new StringBuilder(selectQuery);
  selectQueryBuilder.append(CQLTranslator.ADD_WHERE_CLAUSE);
  translator.buildWhereClause(selectQueryBuilder, columnJavaType, pKeyColumnName, pKeyColumnValue,
    CQLTranslator.EQ_CLAUSE, false);
  selectQueryBuilder.delete(selectQueryBuilder.lastIndexOf(CQLTranslator.AND_CLAUSE),
    selectQueryBuilder.length());
  ResultSet rSet = execute(selectQueryBuilder.toString(), null);
  Iterator<Row> rowIter = rSet.iterator();
  while (rowIter.hasNext()) {
    Row row = rowIter.next();
    DataType dataType = row.getColumnDefinitions().getType(columnName);
    Object columnValue =
      DSClientUtilities.assign(row, null, null, dataType.getName(), null, columnName, null, null);
    results.add(columnValue);
  }
  return results;
}

代码示例来源:origin: Impetus/Kundera

final Row row = rowIter.next();
final ColumnDefinitions columnDefs = row.getColumnDefinitions();

代码示例来源:origin: Impetus/Kundera

/**
 * 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;
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

private boolean isValidPeer(Row peerRow, boolean logIfInvalid) {
 boolean isValid =
   isPeersV2
     ? peerRow.getColumnDefinitions().contains("native_address")
       && peerRow.getColumnDefinitions().contains("native_port")
       && !peerRow.isNull("native_address")
       && !peerRow.isNull("native_port")
     : peerRow.getColumnDefinitions().contains("rpc_address")
       && !peerRow.isNull("rpc_address");
 if (EXTENDED_PEER_CHECK) {
  isValid &=
    peerRow.getColumnDefinitions().contains("host_id")
      && !peerRow.isNull("host_id")
      && peerRow.getColumnDefinitions().contains("data_center")
      && !peerRow.isNull("data_center")
      && peerRow.getColumnDefinitions().contains("rack")
      && !peerRow.isNull("rack")
      && peerRow.getColumnDefinitions().contains("tokens")
      && !peerRow.isNull("tokens");
 }
 if (!isValid && logIfInvalid)
  logger.warn(
    "Found invalid row in system.peers: {}. "
      + "This is likely a gossip or snitch issue, this host will be ignored.",
    formatInvalidPeer(peerRow));
 return isValid;
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

private static InetSocketAddress nativeAddressForPeerHost(
  Row peersRow, InetSocketAddress connectedHost, Cluster.Manager cluster) {
 if (peersRow.getColumnDefinitions().contains("native_address")) {
  InetAddress nativeAddress = peersRow.getInet("native_address");
  int nativePort = peersRow.getInt("native_port");

代码示例来源:origin: pulsarIO/realtime-analytics

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;
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

@Override
 public Tuple apply(Row input) {
  Object[] cols = new Object[input.getColumnDefinitions().size()];
  for (int i = 0; i < input.getColumnDefinitions().size(); i++) {
   cols[i] = input.getObject(i);
  }
  return new Tuple(cols);
 }
};

代码示例来源:origin: hugegraph/hugegraph

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;
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

if (row.getColumnDefinitions().contains("peer")) { // system.peers
 int broadcastPort =
   row.getColumnDefinitions().contains("peer_port") ? row.getInt("peer_port") : 0;
 broadcastAddress = new InetSocketAddress(row.getInet("peer"), broadcastPort);
} else if (row.getColumnDefinitions().contains("broadcast_address")) { // system.local
 int broadcastPort =
   row.getColumnDefinitions().contains("broadcast_port") ? row.getInt("broadcast_port") : 0;
 broadcastAddress = new InetSocketAddress(row.getInet("broadcast_address"), broadcastPort);
if (row.getColumnDefinitions().contains("listen_address")) {
 int listenPort =
   row.getColumnDefinitions().contains("listen_port") ? row.getInt("listen_port") : 0;
 listenAddress = new InetSocketAddress(row.getInet("listen_address"), listenPort);
if (row.getColumnDefinitions().contains("workload")) {
 String dseWorkload = row.getString("workload");
 host.setDseWorkload(dseWorkload);
if (row.getColumnDefinitions().contains("graph")) {
 boolean isDseGraph = row.getBool("graph");
 host.setDseGraphEnabled(isDseGraph);
if (row.getColumnDefinitions().contains("dse_version")) {
 String dseVersion = row.getString("dse_version");
 host.setDseVersion(dseVersion);

代码示例来源:origin: Impetus/Kundera

/**
 * Populates data form secondary tables of entity for given row key.
 * 
 * @param rowId
 *            the row id
 * @param entity
 *            the entity
 * @param metaModel
 *            the meta model
 * @param metadata
 *            the metadata
 */
private void populateSecondaryTableData(Object rowId, Object entity, MetamodelImpl metaModel,
  EntityMetadata metadata) {
  AbstractManagedType managedType = (AbstractManagedType) metaModel.entity(metadata.getEntityClazz());
  List<String> secondaryTables =
    ((DefaultEntityAnnotationProcessor) managedType.getEntityAnnotation()).getSecondaryTablesName();
  for (String tableName : secondaryTables) {
    StringBuilder builder = createSelectQuery(rowId, metadata, tableName);
    ResultSet rSet = this.execute(builder.toString(), null);
    Iterator<Row> rowIter = rSet.iterator();
    Row row = rowIter.next();
    ColumnDefinitions columnDefs = row.getColumnDefinitions();
    Iterator<Definition> columnDefIter = columnDefs.iterator();
    entity = iteratorColumns(metadata, metaModel, metaModel.entity(metadata.getEntityClazz()),
      new HashMap<String, Object>(), entity, row, columnDefIter);
  }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Validates that columns using collections of custom types are properly handled by the driver.
 *
 * @jira_ticket JAVA-1034
 * @test_category metadata
 */
@Test(groups = "short")
public void should_serialize_and_deserialize_collections_of_custom_types() {
 TestUtils.compactStorageSupportCheck(ccm());
 TableMetadata table = cluster().getMetadata().getKeyspace(keyspace).getTable("test_collection");
 assertThat(table.getColumn("c1")).hasType(DataType.list(CUSTOM_DYNAMIC_COMPOSITE));
 assertThat(table.getColumn("c2"))
   .hasType(DataType.map(CUSTOM_DYNAMIC_COMPOSITE, CUSTOM_DYNAMIC_COMPOSITE));
 session()
   .execute(
     "INSERT INTO test_collection(k, c1, c2) VALUES (0, [ 's@foo:i@32' ], { 's@foo:i@32': 's@bar:i@42' })");
 Row r = session().execute("SELECT * FROM test_collection").one();
 assertThat(r.getColumnDefinitions().getType("c1"))
   .isEqualTo(DataType.list(CUSTOM_DYNAMIC_COMPOSITE));
 List<ByteBuffer> c1 = r.getList("c1", ByteBuffer.class);
 assertThat(c1.get(0)).isEqualTo(serializeForDynamicCompositeType("foo", 32));
 assertThat(r.getColumnDefinitions().getType("c2"))
   .isEqualTo(DataType.map(CUSTOM_DYNAMIC_COMPOSITE, CUSTOM_DYNAMIC_COMPOSITE));
 Map<ByteBuffer, ByteBuffer> c2 = r.getMap("c2", ByteBuffer.class, ByteBuffer.class);
 Map.Entry<ByteBuffer, ByteBuffer> entry = c2.entrySet().iterator().next();
 assertThat(entry.getKey()).isEqualTo(serializeForDynamicCompositeType("foo", 32));
 assertThat(entry.getValue()).isEqualTo(serializeForDynamicCompositeType("bar", 42));
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

if (row.getColumnDefinitions().contains(str) && !row.isNull(str))
 c.indexColumns.put(str, row.getString(str));

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

assertThat(r.getColumnDefinitions().getType("c1")).isEqualTo(CUSTOM_DYNAMIC_COMPOSITE);
assertThat(r.getColumnDefinitions().getType("c2")).isEqualTo(CUSTOM_COMPOSITE);
assertThat(r.getColumnDefinitions().getType("c3")).isEqualTo(cint());

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

assertThat(row.getColumnDefinitions().getType("iavg")).isEqualTo(DataType.cfloat());
Float f = row.getFloat("iavg");

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

assertThat(row.getColumnDefinitions().getType("k")).isEqualTo(cint());
assertThat(row.getColumnDefinitions().getType("v")).isEqualTo(custom_udt);

相关文章