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

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

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

ResultSet.getAvailableWithoutFetching介绍

[英]The number of rows that can be retrieved from this result set without blocking to fetch.
[中]可以从此结果集中检索的行数,而无需阻止获取。

代码示例

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

int rowsAvailableWithoutFetching = rs.getAvailableWithoutFetching();
if (rowsAvailableWithoutFetching == 0) {

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

@Override
public void removeTransferLog(
    String queueName, String source, String dest, UUID messageId ) throws QakkaException {
  Statement query = QueryBuilder.select().all().from(TABLE_TRANSFER_LOG)
    .where(   QueryBuilder.eq( COLUMN_QUEUE_NAME, queueName ))
      .and( QueryBuilder.eq( COLUMN_DEST_REGION, dest ))
      .and( QueryBuilder.eq( COLUMN_MESSAGE_ID, messageId ));
  ResultSet rs = cassandraClient.getApplicationSession().execute( query );
  if ( rs.getAvailableWithoutFetching() == 0 ) {
    StringBuilder sb = new StringBuilder();
    sb.append( "Transfer log entry not found for queueName=" ).append( queueName );
    sb.append( " dest=" ).append( dest );
    sb.append( " messageId=" ).append( messageId );
    throw new QakkaException( sb.toString() );
  }
  Statement deleteQuery = QueryBuilder.delete().from(TABLE_TRANSFER_LOG)
      .where(   QueryBuilder.eq( COLUMN_QUEUE_NAME, queueName ))
        .and( QueryBuilder.eq( COLUMN_DEST_REGION, dest ))
      .and( QueryBuilder.eq( COLUMN_MESSAGE_ID, messageId ));
  cassandraClient.getApplicationSession().execute( deleteQuery );
}

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

int rowsAvailableWithoutFetching = rs.getAvailableWithoutFetching();
if (rowsAvailableWithoutFetching == 0) {

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

int numReturned = rs.getAvailableWithoutFetching();
for ( int i=0; i<numReturned; i++ ) {
  Row row = rs.one();

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

@Override
public void onSuccess(ResultSet result) {
 concurrentQueries.release();
 if (executedQueries.incrementAndGet() % 1000 == 0)
  logger.debug(
    "Successfully executed {}.  rows: {}",
    executedQueries.get(),
    result.getAvailableWithoutFetching());
}

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

/**
  * Ensures that when connecting, the driver STARTUP message contains DRIVER_NAME and
  * DRIVER_VERSION configuration in its option map. This should be reflected in the
  * system_views.clients table.
  */
 @Test(groups = "short")
 public void should_send_driver_name_and_version() {
  ResultSet result =
    session().execute("select driver_name, driver_version from system_views.clients");

  // Should be at least 2 connections (1 control connection, 1 pooled connection)
  assertThat(result.getAvailableWithoutFetching()).isGreaterThanOrEqualTo(2);

  for (Row row : result) {
   assertThat(row.getString("driver_version")).isEqualTo(Cluster.getDriverVersion());
   assertThat(row.getString("driver_name")).isEqualTo("DataStax Java Driver");
  }
 }
}

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

public CassandraEntryIterator(ResultSet results, Query query,
    BiFunction<BackendEntry, Row, BackendEntry> merger) {
  super(query);
  this.results = results;
  this.rows = results.iterator();
  this.remaining = results.getAvailableWithoutFetching();
  this.merger = merger;
  this.next = null;
  this.skipOffset();
  if (query.paging()) {
    E.checkState(this.remaining == query.limit() ||
           results.isFullyFetched(),
           "Unexpected fetched page size: %s", this.remaining);
  }
}

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

/**
 * Validates that the "unsafe" paging state can be reused with the same Statement.
 *
 * @test_category paging
 * @expected_result {@link ResultSet} from the query with the provided raw paging state starts
 *     from the subsequent row from the first query.
 */
@Test(groups = "short")
public void should_complete_when_using_unsafe_paging_state() {
 SimpleStatement st = new SimpleStatement(String.format("SELECT v FROM test WHERE k='%s'", KEY));
 ResultSet result = session().execute(st.setFetchSize(20));
 int pageSize = result.getAvailableWithoutFetching();
 byte[] savedPagingState = result.getExecutionInfo().getPagingStateUnsafe();
 st = new SimpleStatement(String.format("SELECT v FROM test WHERE k='%s'", KEY));
 result = session().execute(st.setFetchSize(20).setPagingStateUnsafe(savedPagingState));
 // We have the result starting from the next page we stopped
 assertThat(result.one().getInt("v")).isEqualTo(pageSize);
}

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

assertEquals(rs.getAvailableWithoutFetching(), 5 - (i % 5));
assertEquals(rs.one().getInt(0), i);

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

/**
 * Validates that {@link PagingState} can be reused with the same Statement.
 *
 * @test_category paging
 * @expected_result {@link ResultSet} from the query with the provided {@link PagingState} starts
 *     from the subsequent row from the first query.
 */
@Test(groups = "short")
public void should_complete_when_using_paging_state() {
 SimpleStatement st = new SimpleStatement(String.format("SELECT v FROM test WHERE k='%s'", KEY));
 ResultSet result = session().execute(st.setFetchSize(20));
 int pageSize = result.getAvailableWithoutFetching();
 String savedPagingStateString = result.getExecutionInfo().getPagingState().toString();
 st = new SimpleStatement(String.format("SELECT v FROM test WHERE k='%s'", KEY));
 result =
   session()
     .execute(
       st.setFetchSize(20).setPagingState(PagingState.fromString(savedPagingStateString)));
 // We have the result starting from the next page we stopped
 assertThat(result.one().getInt("v")).isEqualTo(pageSize);
}

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

/**
 * Validates that {@link PagingState} can be reused with the same {@link BoundStatement}.
 *
 * @test_category paging
 * @expected_result {@link ResultSet} from the query with the provided paging state starts from
 *     the subsequent row from the first query.
 */
@Test(groups = "short")
@CassandraVersion("2.0.0")
public void should_be_able_to_use_state_with_bound_statement() {
 PreparedStatement prepared = session().prepare("SELECT v from test where k=?");
 BoundStatement bs = prepared.bind(KEY);
 ResultSet result = session().execute(bs.setFetchSize(20));
 int pageSize = result.getAvailableWithoutFetching();
 PagingState pagingState = result.getExecutionInfo().getPagingState();
 result = session().execute(bs.setFetchSize(20).setPagingState(pagingState));
 // We have the result starting from the next page we stopped
 assertThat(result.one().getInt("v")).isEqualTo(pageSize);
}

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

/**
 * Validates that {@link PagingState} can be reused with a wrapped Statement.
 *
 * @test_category paging
 * @expected_result {@link ResultSet} from the query with the provided {@link PagingState} starts
 *     from the subsequent row from the first query.
 */
@Test(groups = "short")
public void should_use_state_with_wrapped_statement() {
 Statement st =
   new TestWrapper(new SimpleStatement(String.format("SELECT v FROM test WHERE k='%s'", KEY)));
 ResultSet result = session().execute(st.setFetchSize(20));
 int pageSize = result.getAvailableWithoutFetching();
 String savedPagingStateString = result.getExecutionInfo().getPagingState().toString();
 st =
   new TestWrapper(new SimpleStatement(String.format("SELECT v FROM test WHERE k='%s'", KEY)));
 result =
   session()
     .execute(
       st.setFetchSize(20).setPagingState(PagingState.fromString(savedPagingStateString)));
 // We have the result starting from the next page we stopped
 assertThat(result.one().getInt("v")).isEqualTo(pageSize);
}

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

ResultSet result =
  session().execute(select().from(tableName).where(eq("k", 0)).and(eq("c", 0)));
assertThat(result.getAvailableWithoutFetching()).isEqualTo(1);

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

.where(eq("k", "cast_t")));
assertThat(r.getAvailableWithoutFetching()).isEqualTo(4);
for (Row row : r) {
 Integer i = row.getInt("i");

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

assertThat(definitionsBefore).hasSize(3).doesNotContainVariable("d");
int remaining = rows.getAvailableWithoutFetching();
while (remaining-- > 0) {
 try {

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

assertThat(r.getAvailableWithoutFetching()).isEqualTo(2);
assertThat(r.all())
  .extracting(

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

.where(eq("k", "cast_t")));
assertThat(ar.getAvailableWithoutFetching()).isEqualTo(1);
Row row = ar.one();
assertThat(row.getColumnDefinitions().getType("iavg")).isEqualTo(DataType.cfloat());

代码示例来源:origin: io.zipkin.java/zipkin-storage-cassandra

@Override public List<Span> apply(@Nullable ResultSet input) {
  List<Span> result = new ArrayList<>(input.getAvailableWithoutFetching());
  for (Row row : input) {
   result.add(Codec.THRIFT.readSpan(row.getBytes("span")));
  }
  return result;
 }
}

相关文章