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

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

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

Row.getInt介绍

[英]Returns the ith value of this row as an integer.
[中]以整数形式返回此行的第i个值。

代码示例

代码示例来源:origin: Netflix/conductor

@VisibleForTesting
WorkflowMetadata getWorkflowMetadata(String workflowId) {
  ResultSet resultSet = session.execute(selectTotalStatement.bind(UUID.fromString(workflowId)));
  recordCassandraDaoRequests("getWorkflowMetadata");
  return Optional.ofNullable(resultSet.one())
      .map(row -> {
        WorkflowMetadata workflowMetadata = new WorkflowMetadata();
        workflowMetadata.setTotalTasks(row.getInt(TOTAL_TASKS_KEY));
        workflowMetadata.setTotalPartitions(row.getInt(TOTAL_PARTITIONS_KEY));
        return workflowMetadata;
      }).orElseThrow(() -> new ApplicationException(ApplicationException.Code.NOT_FOUND, String.format("Workflow with id: %s not found in data store", workflowId)));
}

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

@Override
public long getLong(int i)
{
  switch (getCassandraType(i)) {
    case INT:
      return currentRow.getInt(i);
    case BIGINT:
    case COUNTER:
      return currentRow.getLong(i);
    case TIMESTAMP:
      return currentRow.getTimestamp(i).getTime();
    case FLOAT:
      return floatToRawIntBits(currentRow.getFloat(i));
    default:
      throw new IllegalStateException("Cannot retrieve long for " + getCassandraType(i));
  }
}

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

return CassandraCqlUtils.quoteStringLiteral(row.getString(i));
case INT:
  return Integer.toString(row.getInt(i));
case BIGINT:
case COUNTER:

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

return row.isNull(col) ? null : row.getInt(col);
return row.getInt(col);

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

@Override
public DatabaseQueue getQueue(String name) {
  logger.trace( "getQueue " + name );
  Clause queueNameClause = QueryBuilder.eq(COLUMN_QUEUE_NAME, name);
  Statement query = QueryBuilder.select().all().from(TABLE_QUEUES)
      .where(queueNameClause);
  Row row = cassandraClient.getApplicationSession().execute(query).one();
  if(row == null){
    return null;
  }
  final String queueName = row.getString(COLUMN_QUEUE_NAME);
  final String regions = row.getString(COLUMN_REGIONS);
  final String defaultDestinations = row.getString(COLUMN_DEFAULT_DESTINATIONS);
  final long defaultDelayMs = row.getLong(COLUMN_DEFAULT_DELAY_MS);
  final int retryCount = row.getInt(COLUMN_RETRY_COUNT);
  final int handlingTimeoutSec = row.getInt(COLUMN_HANDLING_TIMEOUT_SEC);
  final String deadLetterQueue = row.getString(COLUMN_DEAD_LETTER_QUEUE);
  return new DatabaseQueue( queueName, regions, defaultDestinations, defaultDelayMs, retryCount,
      handlingTimeoutSec, deadLetterQueue);
}

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

return row.getInt(i);

代码示例来源:origin: kaaproject/kaa

appId = row.getString(EP_APP_ID_PROPERTY);
serverSideProfile = row.getString(EP_SERVER_PROFILE_PROPERTY);
clientSideProfileVersion = row.getInt(EP_PROFILE_VERSION_PROPERTY);
serverSideProfileVersion = row.getInt(EP_SERVER_PROFILE_VERSION_PROPERTY);

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

return NullableValue.of(nativeType, utf8Slice(row.getString(i)));
case INT:
  return NullableValue.of(nativeType, (long) row.getInt(i));
case BIGINT:
case COUNTER:

代码示例来源:origin: kaaproject/kaa

String userId = row.getString("user_id");
String appToken = row.getString("app_token");
int schemaVersion = row.getInt("schema_version");

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

@Override
 public Integer apply(ResultSet rs) {
  return rs.one().getInt(0);
 }
},

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

private void verifyNextIndexDefinition(
  Iterator<Row> iterator, String name, String options, String type, int index) {
 Row nextIndex = iterator.next();
 assertThat(nextIndex.getString("index_name")).isEqualTo(name);
 assertThat(nextIndex.getString("index_options")).isEqualTo(options);
 assertThat(nextIndex.getString("index_type")).isEqualTo(type);
 assertThat(nextIndex.getInt("component_index")).isEqualTo(index);
}

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

@CassandraVersion("2.0.0")
@Test(groups = "short")
public void should_execute_wrapped_batch_statement() {
 BatchStatement batchStatement = new BatchStatement();
 batchStatement.add(new SimpleStatement(INSERT_QUERY, "key_batch", 1));
 session().execute(new CustomStatement(batchStatement));
 ResultSet rs = session().execute(SELECT_QUERY, "key_batch");
 assertThat(rs.one().getInt("v")).isEqualTo(1);
}

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

@Override
 public ListenableFuture<ResultSet> apply(ResultSet rs) throws Exception {
  int remainingInPage = rs.getAvailableWithoutFetching();
  for (Row row : rs) {
   all.add(row.getInt(0));
   if (--remainingInPage == 0) break;
  }
  boolean wasLastPage = rs.getExecutionInfo().getPagingState() == null;
  if (wasLastPage) return Futures.immediateFuture(rs);
  else return GuavaCompatibility.INSTANCE.transformAsync(rs.fetchMoreResults(), this);
 }
}

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

@CassandraVersion("2.0.0")
@Test(groups = "short")
public void should_execute_wrapped_simple_statement() {
 session().execute(new CustomStatement(new SimpleStatement(INSERT_QUERY, "key_simple", 1)));
 ResultSet rs =
   session().execute(new CustomStatement(new SimpleStatement(SELECT_QUERY, "key_simple")));
 assertThat(rs.one().getInt("v")).isEqualTo(1);
}

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

@CassandraVersion("2.0.0")
@Test(groups = "short")
public void should_add_wrapped_batch_statement_to_batch_statement() {
 BatchStatement batchStatementForWrapping = new BatchStatement();
 batchStatementForWrapping.add(new SimpleStatement(INSERT_QUERY, "key1", 1));
 BatchStatement batchStatement = new BatchStatement();
 batchStatement.add(new CustomStatement(new SimpleStatement(INSERT_QUERY, "key2", 2)));
 batchStatement.add(new CustomStatement(batchStatementForWrapping));
 session().execute(batchStatement);
 ResultSet rs = session().execute(SELECT_QUERY, "key1");
 assertThat(rs.one().getInt("v")).isEqualTo(1);
 rs = session().execute(SELECT_QUERY, "key2");
 assertThat(rs.one().getInt("v")).isEqualTo(2);
}

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

@Test(groups = "short")
public void should_execute_wrapped_bound_statement() {
 PreparedStatement preparedStatement = session().prepare(new SimpleStatement(INSERT_QUERY));
 session().execute(new CustomStatement(preparedStatement.bind("key_bound", 1)));
 preparedStatement = session().prepare(new SimpleStatement(SELECT_QUERY));
 ResultSet rs = session().execute(new CustomStatement(preparedStatement.bind("key_bound")));
 assertThat(rs.one().getInt("v")).isEqualTo(1);
}

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

static void checkExecuteResultSet(ResultSet rs, String key) {
 assertThat(rs.isExhausted()).isFalse();
 Row row = rs.one();
 assertThat(rs.isExhausted()).isTrue();
 assertThat(row.getString("k")).isEqualTo(key);
 assertThat(row.getString("t")).isEqualTo("foo");
 assertThat(row.getInt("i")).isEqualTo(42);
 assertThat(row.getFloat("f")).isEqualTo(24.03f, offset(0.1f));
}

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

private void testWideTable(int key) throws Throwable {
 // Write data
 Insert insertStatement = insertInto("wide_table").value("k", key);
 for (int i = 0; i < 330; ++i) {
  insertStatement = insertStatement.value(createColumnName(i), i);
 }
 session().execute(insertStatement.setConsistencyLevel(ConsistencyLevel.QUORUM));
 // Read data
 Row row = session().execute(select().all().from("wide_table").where(eq("k", key))).one();
 // Verify data
 for (int i = 0; i < 330; ++i) {
  assertTrue(row.getInt(createColumnName(i)) == i);
 }
}

相关文章