use of org.apache.cassandra.db.DataRange in project cassandra by apache.
the class ShortReadPartitionsProtection method makeAndExecuteFetchAdditionalPartitionReadCommand.
private UnfilteredPartitionIterator makeAndExecuteFetchAdditionalPartitionReadCommand(int toQuery) {
PartitionRangeReadCommand cmd = (PartitionRangeReadCommand) command;
DataLimits newLimits = cmd.limits().forShortReadRetry(toQuery);
AbstractBounds<PartitionPosition> bounds = cmd.dataRange().keyRange();
AbstractBounds<PartitionPosition> newBounds = bounds.inclusiveRight() ? new Range<>(lastPartitionKey, bounds.right) : new ExcludingBounds<>(lastPartitionKey, bounds.right);
DataRange newDataRange = cmd.dataRange().forSubRange(newBounds);
ReplicaPlan.ForRangeRead replicaPlan = ReplicaPlans.forSingleReplicaRead(Keyspace.open(command.metadata().keyspace), cmd.dataRange().keyRange(), source, 1);
return executeReadCommand(cmd.withUpdatedLimitsAndDataRange(newLimits, newDataRange), ReplicaPlan.shared(replicaPlan));
}
use of org.apache.cassandra.db.DataRange in project cassandra by apache.
the class SSTableScannerTest method dataRange.
private static DataRange dataRange(TableMetadata metadata, PartitionPosition start, boolean startInclusive, PartitionPosition end, boolean endInclusive) {
Slices.Builder sb = new Slices.Builder(metadata.comparator);
ClusteringIndexSliceFilter filter = new ClusteringIndexSliceFilter(sb.build(), false);
return new DataRange(AbstractBounds.bounds(start, startInclusive, end, endInclusive), filter);
}
use of org.apache.cassandra.db.DataRange in project cassandra by apache.
the class SSTableScannerTest method dataRanges.
private static Iterable<DataRange> dataRanges(TableMetadata metadata, int start, int end, boolean inclusiveStart, boolean inclusiveEnd) {
List<DataRange> ranges = new ArrayList<>();
if (start == end + 1) {
assert !inclusiveStart && inclusiveEnd;
ranges.add(dataRange(metadata, min(start), false, max(end), true));
ranges.add(dataRange(metadata, min(start), false, min(end + 1), true));
ranges.add(dataRange(metadata, max(start - 1), false, max(end), true));
ranges.add(dataRange(metadata, dk(start - 1), false, dk(start - 1), true));
} else {
for (PartitionPosition s : starts(start, inclusiveStart)) {
for (PartitionPosition e : ends(end, inclusiveEnd)) {
if (end < start && e.compareTo(s) > 0)
continue;
if (!isEmpty(new AbstractBounds.Boundary<>(s, inclusiveStart), new AbstractBounds.Boundary<>(e, inclusiveEnd)))
continue;
ranges.add(dataRange(metadata, s, inclusiveStart, e, inclusiveEnd));
}
}
}
return ranges;
}
Aggregations