public class DataRange
extends java.lang.Object
The main "trick" is that the clustering index filter can only be obtained by providing the partition key on which the filter will be applied. This is necessary when paging range queries, as we might need a different filter for the starting key than for other keys (because the previous page we had queried may have ended in the middle of a partition).
Modifier and Type | Class and Description |
---|---|
static class |
DataRange.Paging
Specialized
DataRange used for the paging case. |
static class |
DataRange.Serializer |
Modifier and Type | Field and Description |
---|---|
protected ClusteringIndexFilter |
clusteringIndexFilter |
protected AbstractBounds<PartitionPosition> |
keyRange |
static DataRange.Serializer |
serializer |
Constructor and Description |
---|
DataRange(AbstractBounds<PartitionPosition> range,
ClusteringIndexFilter clusteringIndexFilter)
Creates a
DataRange given a range of partition keys and a clustering index filter. |
Modifier and Type | Method and Description |
---|---|
static DataRange |
allData(IPartitioner partitioner)
Creates a
DataRange to query all data (over the whole ring). |
static DataRange |
allData(IPartitioner partitioner,
ClusteringIndexFilter filter)
Creates a
DataRange to query all partitions of the ring using the provided
clustering index filter. |
static void |
appendKeyString(java.lang.StringBuilder sb,
AbstractType<?> type,
java.nio.ByteBuffer key) |
ClusteringIndexFilter |
clusteringIndexFilter(DecoratedKey key)
The clustering index filter to use for the provided key.
|
boolean |
contains(PartitionPosition pos)
Whether the provided ring position is covered by this
DataRange . |
static DataRange |
forKeyRange(Range<PartitionPosition> keyRange)
Creates a
DataRange to query all rows over the provided key range. |
DataRange |
forPaging(AbstractBounds<PartitionPosition> range,
ClusteringComparator comparator,
Clustering<?> lastReturned,
boolean inclusive)
Returns a new
DataRange for use when paging this range. |
DataRange |
forSubRange(AbstractBounds<PartitionPosition> range)
Returns a new
DataRange equivalent to this one but restricted to the provided sub-range. |
static DataRange |
forTokenRange(Range<Token> tokenRange)
Creates a
DataRange to query all rows over the provided token range. |
boolean |
isNamesQuery()
Whether the underlying clustering index filter is a names filter or not.
|
boolean |
isPaging()
Whether the data range is for a paged request or not.
|
boolean |
isReversed()
Whether the underlying
ClusteringIndexFilter is reversed or not. |
boolean |
isUnrestricted()
Whether this
DataRange queries everything (has no restriction neither on the
partition queried, nor within the queried partition). |
boolean |
isWrapAround()
Whether the range queried by this
DataRange actually wraps around. |
AbstractBounds<PartitionPosition> |
keyRange()
The range of partition key queried by this
DataRange . |
boolean |
selectsAllPartition() |
PartitionPosition |
startKey()
The start of the partition key range queried by this
DataRange . |
PartitionPosition |
stopKey()
The end of the partition key range queried by this
DataRange . |
java.lang.String |
toCQLString(TableMetadata metadata) |
java.lang.String |
toString(TableMetadata metadata) |
public static final DataRange.Serializer serializer
protected final AbstractBounds<PartitionPosition> keyRange
protected final ClusteringIndexFilter clusteringIndexFilter
public DataRange(AbstractBounds<PartitionPosition> range, ClusteringIndexFilter clusteringIndexFilter)
DataRange
given a range of partition keys and a clustering index filter. The
return DataRange
will return the same filter for all keys.range
- the range over partition keys to use.clusteringIndexFilter
- the clustering index filter to use.public static DataRange allData(IPartitioner partitioner)
DataRange
to query all data (over the whole ring).partitioner
- the partitioner in use for the table.DataRange
.public static DataRange forTokenRange(Range<Token> tokenRange)
DataRange
to query all rows over the provided token range.tokenRange
- the (partition key) token range to query.DataRange
.public static DataRange forKeyRange(Range<PartitionPosition> keyRange)
DataRange
to query all rows over the provided key range.keyRange
- the (partition key) range to query.DataRange
.public static DataRange allData(IPartitioner partitioner, ClusteringIndexFilter filter)
DataRange
to query all partitions of the ring using the provided
clustering index filter.partitioner
- the partitioner in use for the table queried.filter
- the clustering index filter to use.DataRange
.public AbstractBounds<PartitionPosition> keyRange()
DataRange
.DataRange
.public PartitionPosition startKey()
DataRange
.DataRange
.public PartitionPosition stopKey()
DataRange
.DataRange
.public boolean isNamesQuery()
public boolean isPaging()
public boolean isWrapAround()
DataRange
actually wraps around.DataRange
actually wraps around.public boolean contains(PartitionPosition pos)
DataRange
.DataRange
.public boolean isUnrestricted()
DataRange
queries everything (has no restriction neither on the
partition queried, nor within the queried partition).DataRange
queries everything.public boolean selectsAllPartition()
public boolean isReversed()
ClusteringIndexFilter
is reversed or not.ClusteringIndexFilter
is reversed or not.public ClusteringIndexFilter clusteringIndexFilter(DecoratedKey key)
This may or may not be the same filter for all keys (that is, paging range use a different filter for their start key).
key
- the partition key for which we want the clustering index filter.key
.public DataRange forPaging(AbstractBounds<PartitionPosition> range, ClusteringComparator comparator, Clustering<?> lastReturned, boolean inclusive)
DataRange
for use when paging this
range.range
- the range of partition keys to query.comparator
- the comparator for the table queried.lastReturned
- the clustering for the last result returned by the previous page, i.e. the result we want to start our new page
from. This last returned must correspond to left bound of range
(in other words, range.left
must be the
partition key for that lastReturned
result).inclusive
- whether or not we want to include the lastReturned
in the newly returned page of results.DataRange
suitable for paging this
range given the lastRetuned
result of the previous page.public DataRange forSubRange(AbstractBounds<PartitionPosition> range)
DataRange
equivalent to this
one but restricted to the provided sub-range.range
- the sub-range to use for the newly returned data range. Note that assumes that range
is a proper
sub-range of the initial range but doesn't validate it. You should make sure to only provided sub-ranges however or this
might throw off the paging case (see Paging.forSubRange()).DataRange
using range
as partition key range and the clustering index filter filter from this
.public java.lang.String toString(TableMetadata metadata)
public java.lang.String toCQLString(TableMetadata metadata)
public static void appendKeyString(java.lang.StringBuilder sb, AbstractType<?> type, java.nio.ByteBuffer key)
Copyright © 2009-2021 The Apache Software Foundation