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

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

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

Row.getSet介绍

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

代码示例

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

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

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

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

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

private static Set<Integer> queryByNameIndex(
                CassandraSessionPool.Session session,
                String table, String name) {
    if (name.isEmpty()) {
      return ImmutableSet.of();
    }
    Select select = QueryBuilder.select().from(table);
    select.where(CassandraTable.formatEQ(HugeKeys.NAME, name));
    try {
      Iterator<Row> it = session.execute(select).iterator();
      if (!it.hasNext()) {
        return ImmutableSet.of();
      }
      Set<Integer> ids = it.next().getSet(ELEMENT_IDS, Integer.class);
      assert !it.hasNext();
      return ids;
    } catch (DriverException e) {
      throw new BackendException("Failed to query by name '%s'",
                    e, name);
    }
  }
}

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

private static Set<String> queryByLabelIndex(
              CassandraSessionPool.Session session,
              String table, Id label) {
  Select select = QueryBuilder.select().from(table);
  select.where(CassandraTable.formatEQ(HugeKeys.LABEL, label.asLong()));
  try {
    Iterator<Row> it = session.execute(select).iterator();
    if (!it.hasNext()) {
      return ImmutableSet.of();
    }
    Set<String> ids = it.next().getSet(ELEMENT_IDS, String.class);
    assert !it.hasNext();
    return ids;
  } catch (DriverException e) {
    throw new BackendException("Failed to query by label '%s'",
                  e, label);
  }
}

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

updateInfo(host, localRow, cluster, isInitialConnection);
if (metadataEnabled && factory != null) {
 Set<String> tokensStr = localRow.getSet("tokens", String.class);
 if (!tokensStr.isEmpty()) {
  Set<Token> tokens = toTokens(factory, tokensStr);
Set<String> tokensStr = row.getSet("tokens", String.class);
Set<Token> tokens = null;
if (!tokensStr.isEmpty()) {

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

retVal = row.getSet(columnName, setClazz);
Collection resultSet = new HashSet();
if (isElementCollectionSet)

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

boolean isCompact;
if (cassandraVersion.getMajor() > 2) {
 Set<String> flags = row.getSet(FLAGS, String.class);
 isDense = flags.contains(DENSE);
 boolean isSuper = flags.contains(SUPER);

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

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

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

/**
 * Extrat permissions from the row returned by cassandra.
 *  
 * @param row
 *      current cassandra row
 * @return
 *      target permission set
 */
public static Set < String > mapFeaturePermissions(Row row) {
  return row.getSet(COL_FEAT_ROLES, String.class);
}

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

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

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

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

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

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

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

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

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

@Test(groups = "short")
public void should_delete_set_element() throws Exception {
 // given
 session().execute("INSERT INTO test_coll (k, c) VALUES (1, {'foo','bar','qix'})");
 // when
 BuiltStatement statement = delete().setElt("c", "foo").from("test_coll").where(eq("k", 1));
 session().execute(statement);
 // then
 Set<String> actual =
   session().execute("SELECT c FROM test_coll WHERE k = 1").one().getSet("c", String.class);
 assertThat(actual).containsOnly("bar", "qix");
}

代码示例来源: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_delete_set_element_with_bind_marker() throws Exception {
 // given
 session().execute("INSERT INTO test_coll (k, c) VALUES (1, {'foo','bar','qix'})");
 // when
 BuiltStatement statement =
   delete().setElt("c", bindMarker()).from("test_coll").where(eq("k", 1));
 PreparedStatement ps = session().prepare(statement);
 session().execute(ps.bind("foo"));
 // then
 Set<String> actual =
   session().execute("SELECT c FROM test_coll WHERE k = 1").one().getSet("c", String.class);
 assertThat(actual).containsOnly("bar", "qix");
}

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

@Test(groups = "short")
public void should_handle_contains_on_set_with_index() {
 PreparedStatement byCategory =
   session()
     .prepare(
       select("id", "description", "categories")
         .from("products")
         .where(contains("categories", bindMarker("category"))));
 ResultSet results = session().execute(byCategory.bind().setString("category", "hdtv"));
 assertThat(results.getAvailableWithoutFetching()).isEqualTo(2);
 for (Row row : results) {
  assertThat(row.getSet("categories", String.class)).contains("hdtv");
 }
}

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

.one();
Set<String> tokenStrings = row.getSet("tokens", String.class);
assertThat(tokenStrings).hasSize(numTokens);
Iterable<Token> tokensFromSystemTable =

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

.isEqualTo(mapping.value);
assertThat(row.getSet("s", TypeTokens.listOf(mapping.javaType))).isEqualTo(set);
  .isEqualTo(mapping.value);
assertThat(row.getSet(4, TypeTokens.listOf(mapping.javaType))).isEqualTo(set);

代码示例来源:origin: adejanovski/cassandra-jdbc-wrapper

public Set<?> getSet(int index) throws SQLException
{
  checkIndex(index);        
  try {
    return currentRow.getSet(index-1,Class.forName(DataTypeEnum.fromCqlTypeName(currentRow.getColumnDefinitions().getType(index-1).getTypeArguments().get(0).getName()).asJavaClass().getCanonicalName()));
  } catch (ClassNotFoundException e) {
    logger.warn("Error while performing getSet()", e);
  }
  return null;
}

相关文章