int rowsAvailableWithoutFetching = rs.getAvailableWithoutFetching(); if (rowsAvailableWithoutFetching == 0) {
@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 ); }
int rowsAvailableWithoutFetching = rs.getAvailableWithoutFetching(); if (rowsAvailableWithoutFetching == 0) {
int numReturned = rs.getAvailableWithoutFetching(); for ( int i=0; i<numReturned; i++ ) { Row row = rs.one();
@Override public void onSuccess(ResultSet result) { concurrentQueries.release(); if (executedQueries.incrementAndGet() % 1000 == 0) logger.debug( "Successfully executed {}. rows: {}", executedQueries.get(), result.getAvailableWithoutFetching()); }
/** * 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"); } } }
@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); } }
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); } }
/** * 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); }
assertEquals(rs.getAvailableWithoutFetching(), 5 - (i % 5)); assertEquals(rs.one().getInt(0), i);
/** * 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); }
/** * 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); }
/** * 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); }
@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"); } }
ResultSet result = session().execute(select().from(tableName).where(eq("k", 0)).and(eq("c", 0))); assertThat(result.getAvailableWithoutFetching()).isEqualTo(1);
.where(eq("k", "cast_t"))); assertThat(r.getAvailableWithoutFetching()).isEqualTo(4); for (Row row : r) { Integer i = row.getInt("i");
assertThat(definitionsBefore).hasSize(3).doesNotContainVariable("d"); int remaining = rows.getAvailableWithoutFetching(); while (remaining-- > 0) { try {
assertThat(r.getAvailableWithoutFetching()).isEqualTo(2); assertThat(r.all()) .extracting(
.where(eq("k", "cast_t"))); assertThat(ar.getAvailableWithoutFetching()).isEqualTo(1); Row row = ar.one(); assertThat(row.getColumnDefinitions().getType("iavg")).isEqualTo(DataType.cfloat());
@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; } }