1. The Row key that I am looking for doesnt exists so cassandra returns 0 results2. the row key exists but now it is the last page so cassandra where cassandra return 0 (no more results available)what does isExhausted() will do in case 1?
--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.
if isExhausted() returns true in both cases that it isn't helpful right. any other methods in ResultSet or somewhere where I can differentiate the two cases? I open to changing the logic that I control as long as I can differentiate the two cases.
Every http request that I get in my microservice I fetch one page by doing...
public void loadSeriesInOrder(ByteBuffer byteBuffer, ByteBuffer pageContext, int fetchSize, boolean reverseOrder, AsyncMethodCallback asyncMethodCallback) throws TException {
ListenableFuture<ResultSet> paginatedForwardReferenceSeriesFuture = new ForwardReferenceSeries().getForwardRefernceSeriesAsync(byteBuffer, pageContext, fetchSize, reverseOrder);
ListenableFuture<LoadSeriesResponse> loadSeriesResponseFuture = Futures.transform(paginatedForwardReferenceSeriesFuture, new Function<ResultSet, LoadSeriesResponse>() {
public LoadSeriesResponse apply(ResultSet forwardReferenceSeriesResultSet) {
//Mapper<ForwardReferenceSeries> mapperForwardReferenceSeries = manager.mapper(ForwardReferenceSeries.class);
Mapper<ForwardReferenceSeries> mapperForwardReferenceSeries = forwardReferenceSeriesMapper;
Result<ForwardReferenceSeries> forwardReferenceSeriesPage = mapperForwardReferenceSeries.map(forwardReferenceSeriesResultSet);
List<ByteBuffer> forwardReferenceSeriesValues = new LinkedList<>();
while(forwardReferenceSeriesResultSet.getAvailableWithoutFetching() > 0) { //just return the rows from the cache instead of fetching from db
forwardReferenceSeriesValues.add(forwardReferenceSeriesPage.one().getDataIdentity());
}
PagingState nextPaginatedState = forwardReferenceSeriesPage.getExecutionInfo().getPagingState(); //Paginated state represents where we are in the Result Set so we can send the context for the next iteration
LoadSeriesResponse loadPaginatedSeriesResponse = new LoadSeriesResponse();
if (nextPaginatedState == null) {
loadPaginatedSeriesResponse.setNext_page_context(new byte[]{});
} else {
loadPaginatedSeriesResponse.setNext_page_context(nextPaginatedState.toBytes());
}
loadPaginatedSeriesResponse.setValues(forwardReferenceSeriesValues);
return loadPaginatedSeriesResponse;
}
});
}
Also I thought you said isExhausted is not meant to check if there are results but now you are stating the contrary?
isExhausted isn't really meant for this purpose though. It's for indicating if there are any rows left to consumed, not if there were ever any rows returned.
--
Olivier Michallat
Driver & tools engineer, DataStax