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

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

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

Row.getList介绍

[英]Returns the ith value of this row as a list.
[中]以列表形式返回此行的第i个值。

代码示例

代码示例来源:origin: prestodb/presto

private static String buildListValue(Row row, int i, CassandraType elemType)
{
  return buildArrayValue(row.getList(i, elemType.javaType), elemType);
}

代码示例来源:origin: apache/nifi

return row.getSet(i, firstCodec.getJavaType());
} else if (dataType.equals(DataType.list(firstArg))) {
  return row.getList(i, firstCodec.getJavaType());
} else {

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

private boolean dependsOn(Row udt1, Row udt2, Cluster cluster, String keyspace) {
 List<String> fieldTypes = udt1.getList(UserType.COLS_TYPES, String.class);
 String typeName = udt2.getString(UserType.TYPE_NAME);
 for (String fieldTypeStr : fieldTypes) {
  // use shallow user types since some definitions might not be known at this stage
  DataType fieldType =
    DataTypeCqlNameParser.parse(fieldTypeStr, cluster, keyspace, null, null, false, true);
  if (references(fieldType, typeName)) return true;
 }
 return false;
}

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

static UserType build(
  KeyspaceMetadata ksm,
  Row row,
  VersionNumber version,
  Cluster cluster,
  Map<String, UserType> userTypes) {
 ProtocolVersion protocolVersion =
   cluster.getConfiguration().getProtocolOptions().getProtocolVersion();
 CodecRegistry codecRegistry = cluster.getConfiguration().getCodecRegistry();
 String keyspace = row.getString(KeyspaceMetadata.KS_NAME);
 String name = row.getString(TYPE_NAME);
 List<String> fieldNames = row.getList(COLS_NAMES, String.class);
 List<String> fieldTypes = row.getList(COLS_TYPES, String.class);
 List<Field> fields = new ArrayList<Field>(fieldNames.size());
 for (int i = 0; i < fieldNames.size(); i++) {
  DataType fieldType;
  if (version.getMajor() >= 3.0) {
   fieldType =
     DataTypeCqlNameParser.parse(
       fieldTypes.get(i), cluster, ksm.getName(), userTypes, ksm.userTypes, false, false);
  } else {
   fieldType =
     DataTypeClassNameParser.parseOne(fieldTypes.get(i), protocolVersion, codecRegistry);
  }
  fields.add(new Field(fieldNames.get(i), fieldType));
 }
 return new UserType(keyspace, name, false, fields, protocolVersion, codecRegistry);
}

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

private void assertRow(Row row) {
 assertThat(row.getInt(0)).isEqualTo(42);
 assertThat(row.getObject(0)).isEqualTo(42); // uses the default codec
 assertThat(row.get(0, Integer.class)).isEqualTo(42);
 assertThat(row.get(0, String.class)).isEqualTo("42");
 assertThat(row.getList(1, Integer.class)).isEqualTo(newArrayList(42));
 assertThat(row.getList(1, String.class)).isEqualTo(newArrayList("42"));
 assertThat(row.getObject(1)).isEqualTo(newArrayList(42)); // uses the default codec
 assertThat(row.get(1, TypeTokens.listOf(Integer.class))).isEqualTo(newArrayList(42));
 assertThat(row.get(1, TypeTokens.listOf(String.class))).isEqualTo(newArrayList("42"));
}

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

private void assertRow(Row row) {
 assertThat(row.getList(1, elementsType)).isEqualTo(v);
 assertThat(row.get(1, listType)).isEqualTo(v);
}

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

cluster.getConfiguration().getProtocolOptions().getProtocolVersion();
String simpleName = row.getString("function_name");
List<String> argumentNames = row.getList("argument_names", String.class);
List<String> argumentTypes = row.getList("argument_types", String.class);
Map<String, DataType> arguments =
  buildArguments(ksm, argumentNames, argumentTypes, version, cluster);

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

retVal = row.getList(columnName, listClazz);
Collection resultList = new ArrayList();
if (isElementCollectionList)

代码示例来源:origin: org.apache.cassandra/cassandra-all

@Override
public <T> List<T> getList(int i, TypeToken<T> typeToken)
{
  return row.getList(i, typeToken);
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

@Override
public <T> List<T> getList(String name, Class<T> elementsClass)
{
  return row.getList(name, elementsClass);
}

代码示例来源:origin: jsevellec/cassandra-unit

@Override
public <T> List<T> getList(int i, Class<T> elementsClass)
{
  return row.getList(i, elementsClass);
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

@Override
public <T> List<T> getList(int i, Class<T> elementsClass)
{
  return row.getList(i, elementsClass);
}

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

@Test(groups = "short")
public void should_delete_list_element() throws Exception {
 // given
 session().execute("INSERT INTO test_coll (k, a, b) VALUES (1, [1,2,3], null)");
 // when
 BuiltStatement statement = delete().listElt("a", 1).from("test_coll").where(eq("k", 1));
 session().execute(statement);
 // then
 List<Integer> actual =
   session().execute("SELECT a FROM test_coll WHERE k = 1").one().getList("a", Integer.class);
 assertThat(actual).containsExactly(1, 3);
}

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

private void assertRow(Row row) {
  assertThat(row.getInt(0)).isEqualTo(n_int);
  assertThat(row.getList(1, Integer.class)).isEqualTo(l_int);
  assertThat(row.getList(2, Long.class)).isEqualTo(l_bigint);
  assertThat(row.getSet(3, Float.class)).isEqualTo(s_float);
  assertThat(row.getSet(4, Double.class)).isEqualTo(s_double);
  assertThat(row.getMap(5, Integer.class, BigInteger.class)).isEqualTo(m_varint);
  assertThat(row.getMap(6, Integer.class, BigDecimal.class)).isEqualTo(m_decimal);
  // with get + type
  assertThat(row.get(1, TypeTokens.listOf(Integer.class))).isEqualTo(l_int);
  assertThat(row.get(2, TypeTokens.listOf(Long.class))).isEqualTo(l_bigint);
  assertThat(row.get(3, TypeTokens.setOf(Float.class))).isEqualTo(s_float);
  assertThat(row.get(4, TypeTokens.setOf(Double.class))).isEqualTo(s_double);
  assertThat(row.get(5, TypeTokens.mapOf(Integer.class, BigInteger.class))).isEqualTo(m_varint);
  assertThat(row.get(6, TypeTokens.mapOf(Integer.class, BigDecimal.class))).isEqualTo(m_decimal);
  // with getObject
  assertThat(row.getObject(1)).isEqualTo(l_int);
  assertThat(row.getObject(2)).isEqualTo(l_bigint);
  assertThat(row.getObject(3)).isEqualTo(s_float);
  assertThat(row.getObject(4)).isEqualTo(s_double);
  assertThat(row.getObject(5)).isEqualTo(m_varint);
  assertThat(row.getObject(6)).isEqualTo(m_decimal);
 }
}

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

@Test(groups = "short")
public void should_handle_collections_of_UDT() throws Exception {
 UserType udtType = cluster().getMetadata().getKeyspace(keyspace).getUserType("udt");
 UDTValue udtValue =
   udtType.newValue().setInt("i", 2).setInet("a", InetAddress.getByName("localhost"));
 UDTValue udtValue2 =
   udtType.newValue().setInt("i", 3).setInet("a", InetAddress.getByName("localhost"));
 Statement insert = insertInto("udtTest").value("k", 1).value("l", ImmutableList.of(udtValue));
 assertThat(insert.toString())
   .isEqualTo("INSERT INTO udtTest (k,l) VALUES (1,[{i:2,a:'127.0.0.1'}]);");
 session().execute(insert);
 List<Row> rows = session().execute(select().from("udtTest").where(eq("k", 1))).all();
 assertThat(rows.size()).isEqualTo(1);
 Row r1 = rows.get(0);
 assertThat(r1.getList("l", UDTValue.class).get(0).getInet("a").getHostAddress())
   .isEqualTo("127.0.0.1");
 Map<Integer, UDTValue> map = Maps.newHashMap();
 map.put(0, udtValue);
 map.put(2, udtValue2);
 Statement updateMap = update("udtTest").with(putAll("m", map)).where(eq("k", 1));
 assertThat(updateMap.toString())
   .isEqualTo(
     "UPDATE udtTest SET m=m+{0:{i:2,a:'127.0.0.1'},2:{i:3,a:'127.0.0.1'}} WHERE k=1;");
 session().execute(updateMap);
 rows = session().execute(select().from("udtTest").where(eq("k", 1))).all();
 r1 = rows.get(0);
 assertThat(r1.getMap("m", Integer.class, UDTValue.class)).isEqualTo(map);
}

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

@Test(groups = "short")
public void should_delete_list_element_with_bind_marker() throws Exception {
 // given
 session().execute("INSERT INTO test_coll (k, a) VALUES (1, [1,2,3])");
 // when
 BuiltStatement statement =
   delete().listElt("a", bindMarker()).from("test_coll").where(eq("k", 1));
 PreparedStatement ps = session().prepare(statement);
 session().execute(ps.bind(1));
 // then
 List<Integer> actual =
   session().execute("SELECT a FROM test_coll WHERE k = 1").one().getList("a", Integer.class);
 assertThat(actual).containsExactly(1, 3);
}

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

@Test(groups = "short")
public void should_handle_contains_on_list_with_index() {
 PreparedStatement byBuyer =
   session()
     .prepare(
       select("id", "description", "buyers")
         .from("products")
         .where(contains("buyers", bindMarker("buyer"))));
 ResultSet results = session().execute(byBuyer.bind().setInt("buyer", 4));
 Row row = results.one();
 assertThat(row).isNotNull();
 assertThat(row.getInt("id")).isEqualTo(38471);
 assertThat(row.getList("buyers", Integer.class)).contains(4);
}

代码示例来源: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

assertThat(row.getList("l", mapping.codec.getJavaType())).isEqualTo(list);
assertThat(row.getMap("m", mapping.codec.getJavaType(), mapping.codec.getJavaType()))
  .isEqualTo(map);
assertThat(row.getList(1, mapping.codec.getJavaType())).isEqualTo(list);
assertThat(row.getMap(2, mapping.codec.getJavaType(), mapping.codec.getJavaType()))
  .isEqualTo(map);

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

String simpleName = row.getString("aggregate_name");
List<DataType> argumentTypes =
  parseTypes(ksm, row.getList("argument_types", String.class), version, cluster);
String finalFuncSimpleName = row.getString("final_func");
DataType returnType;

相关文章