use of org.apache.cassandra.db.filter.DataLimits in project cassandra by apache.
the class PartitionRangeQueryPager method nextPageReadCommand.
protected ReadCommand nextPageReadCommand(int pageSize) throws RequestExecutionException {
DataLimits limits;
DataRange fullRange = ((PartitionRangeReadCommand) command).dataRange();
DataRange pageRange;
if (lastReturnedKey == null) {
pageRange = fullRange;
limits = command.limits().forPaging(pageSize);
} else {
// We want to include the last returned key only if we haven't achieved our per-partition limit, otherwise, don't bother.
boolean includeLastKey = remainingInPartition() > 0 && lastReturnedRow != null;
AbstractBounds<PartitionPosition> bounds = makeKeyBounds(lastReturnedKey, includeLastKey);
if (includeLastKey) {
pageRange = fullRange.forPaging(bounds, command.metadata().comparator, lastReturnedRow.clustering(command.metadata()), false);
limits = command.limits().forPaging(pageSize, lastReturnedKey.getKey(), remainingInPartition());
} else {
pageRange = fullRange.forSubRange(bounds);
limits = command.limits().forPaging(pageSize);
}
}
Index index = command.getIndex(Keyspace.openAndGetStore(command.metadata()));
Optional<IndexMetadata> indexMetadata = index != null ? Optional.of(index.getIndexMetadata()) : Optional.empty();
return new PartitionRangeReadCommand(command.metadata(), command.nowInSec(), command.columnFilter(), command.rowFilter(), limits, pageRange, indexMetadata);
}
Aggregations