You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Followed the example given below, CosmosPagedIterable.byPage is loading multiple pages with single query and do while loop is getting executed only once.
String query = "SELECT * FROM Families";
int pageSize = 100; //No of docs per page
int currentPageNumber = 1;
int documentNumber = 0;
String continuationToken = null;
double requestCharge = 0.0;
// First iteration (continuationToken = null): Receive a batch of query response pages
// Subsequent iterations (continuationToken != null): Receive subsequent batch of query response pages, with continuationToken indicating where the previous iteration left off
do {
logger.info("Receiving a set of query response pages.");
logger.info("Continuation Token: " + continuationToken + "\n");
CosmosQueryRequestOptions queryOptions = new CosmosQueryRequestOptions();
Iterable<FeedResponse<Family>> feedResponseIterator =
container.queryItems(query, queryOptions, Family.class).iterableByPage(continuationToken,pageSize);
for (FeedResponse<Family> page : feedResponseIterator) {
logger.info(String.format("Current page number: %d", currentPageNumber));
// Access all of the documents in this result page
for (Family docProps : page.getResults()) {
documentNumber++;
}
// Accumulate the request charge of this page
requestCharge += page.getRequestCharge();
// Page count so far
logger.info(String.format("Total documents received so far: %d", documentNumber));
// Request charge so far
logger.info(String.format("Total request charge so far: %f\n", requestCharge));
// Along with page results, get a continuation token
// which enables the client to "pick up where it left off"
// in accessing query response pages.
continuationToken = page.getContinuationToken();
currentPageNumber++;
}
} while (continuationToken != null);
The text was updated successfully, but these errors were encountered:
Followed the example given below, CosmosPagedIterable.byPage is loading multiple pages with single query and do while loop is getting executed only once.
String query = "SELECT * FROM Families";
The text was updated successfully, but these errors were encountered: