Search in sources :

Example 1 with DataRange

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));
}
Also used : ReplicaPlan(org.apache.cassandra.locator.ReplicaPlan) PartitionRangeReadCommand(org.apache.cassandra.db.PartitionRangeReadCommand) PartitionPosition(org.apache.cassandra.db.PartitionPosition) DataRange(org.apache.cassandra.db.DataRange) DataLimits(org.apache.cassandra.db.filter.DataLimits)

Example 2 with DataRange

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);
}
Also used : ClusteringIndexSliceFilter(org.apache.cassandra.db.filter.ClusteringIndexSliceFilter) Slices(org.apache.cassandra.db.Slices) RowUpdateBuilder(org.apache.cassandra.db.RowUpdateBuilder) DataRange(org.apache.cassandra.db.DataRange)

Example 3 with DataRange

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;
}
Also used : PartitionPosition(org.apache.cassandra.db.PartitionPosition) ArrayList(java.util.ArrayList) DataRange(org.apache.cassandra.db.DataRange)

Aggregations

DataRange (org.apache.cassandra.db.DataRange)3 PartitionPosition (org.apache.cassandra.db.PartitionPosition)2 ArrayList (java.util.ArrayList)1 PartitionRangeReadCommand (org.apache.cassandra.db.PartitionRangeReadCommand)1 RowUpdateBuilder (org.apache.cassandra.db.RowUpdateBuilder)1 Slices (org.apache.cassandra.db.Slices)1 ClusteringIndexSliceFilter (org.apache.cassandra.db.filter.ClusteringIndexSliceFilter)1 DataLimits (org.apache.cassandra.db.filter.DataLimits)1 ReplicaPlan (org.apache.cassandra.locator.ReplicaPlan)1