// If we are within a shard already, get more results from this shard
Row row = page.get(nextItem);
UUID uuid = row.getUUID("id");
statementIterator.setNextUuid(uuid);
CQLStatement cql = statementIterator.next();
ResultSet resultSet = cqlExecutor.executeSync(cql);
statementNumber++;
populatePage(resultSet);
if (page.size() > pageSize) {
moreResultsInShard = true;
} else {
moreResultsInShard = false;
}
nextItem = 0;
} else {
// Reset our current shard state
nextItem = 0;
page = null;
moreResultsInShard = false;
// Start going through the remaining shards until we find one with results or hit the last one
while (statementIterator.hasNext()) {
// Move to the next shard in the iterator and reset the limits and stuff
statementIterator.setLimit(pageSize + 1l);
statementIterator.nextShard();
statementIterator.setNextUuid(null);
CQLStatement cql = statementIterator.next();
ResultSet resultSet = cqlExecutor.executeSync(cql);
statementNumber++;
if (!resultSet.isExhausted()) {
populatePage(resultSet);
if (page.size() > pageSize) {
moreResultsInShard = true;
} else {
moreResultsInShard = false;