Package org.apache.cassandra.db
Class DataRange
java.lang.Object
org.apache.cassandra.db.DataRange
- Direct Known Subclasses:
DataRange.Paging
Groups both the range of partitions to query, and the clustering index filter to
apply for each partition (for a (partition) range query).
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).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSpecializedDataRangeused for the paging case.static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ClusteringIndexFilterprotected final AbstractBounds<PartitionPosition>static final DataRange.Serializer -
Constructor Summary
ConstructorsConstructorDescriptionDataRange(AbstractBounds<PartitionPosition> range, ClusteringIndexFilter clusteringIndexFilter) Creates aDataRangegiven a range of partition keys and a clustering index filter. -
Method Summary
Modifier and TypeMethodDescriptionstatic DataRangeallData(IPartitioner partitioner) Creates aDataRangeto query all data (over the whole ring).static DataRangeallData(IPartitioner partitioner, ClusteringIndexFilter filter) Creates aDataRangeto query all partitions of the ring using the provided clustering index filter.static voidappendKeyString(StringBuilder sb, AbstractType<?> type, ByteBuffer key) The clustering index filter to use for the provided key.booleanWhether the provided ring position is covered by thisDataRange.static DataRangeforKeyRange(Range<PartitionPosition> keyRange) Creates aDataRangeto query all rows over the provided key range.forPaging(AbstractBounds<PartitionPosition> range, ClusteringComparator comparator, Clustering<?> lastReturned, boolean inclusive) Returns a newDataRangefor use when pagingthisrange.Returns a newDataRangeequivalent tothisone but restricted to the provided sub-range.static DataRangeforTokenRange(Range<Token> tokenRange) Creates aDataRangeto query all rows over the provided token range.booleanWhether the underlying clustering index filter is a names filter or not.booleanisPaging()Whether the data range is for a paged request or not.booleanWhether the underlyingClusteringIndexFilteris reversed or not.booleanisUnrestricted(TableMetadata metadata) Whether thisDataRangequeries everything (has no restriction neither on the partition queried, nor within the queried partition).booleanWhether the range queried by thisDataRangeactually wraps around.keyRange()The range of partition key queried by thisDataRange.booleanThe start of the partition key range queried by thisDataRange.startKey()The start of the partition key range queried by thisDataRange.The end of the partition key range queried by thisDataRange.stopKey()The end of the partition key range queried by thisDataRange.toCQLString(TableMetadata metadata, RowFilter rowFilter) toString(TableMetadata metadata)
-
Field Details
-
serializer
-
keyRange
-
clusteringIndexFilter
-
-
Constructor Details
-
DataRange
public DataRange(AbstractBounds<PartitionPosition> range, ClusteringIndexFilter clusteringIndexFilter) Creates aDataRangegiven a range of partition keys and a clustering index filter. The returnDataRangewill return the same filter for all keys.- Parameters:
range- the range over partition keys to use.clusteringIndexFilter- the clustering index filter to use.
-
-
Method Details
-
allData
Creates aDataRangeto query all data (over the whole ring).- Parameters:
partitioner- the partitioner in use for the table.- Returns:
- the newly create
DataRange.
-
forTokenRange
Creates aDataRangeto query all rows over the provided token range.- Parameters:
tokenRange- the (partition key) token range to query.- Returns:
- the newly create
DataRange.
-
forKeyRange
Creates aDataRangeto query all rows over the provided key range.- Parameters:
keyRange- the (partition key) range to query.- Returns:
- the newly create
DataRange.
-
allData
Creates aDataRangeto query all partitions of the ring using the provided clustering index filter.- Parameters:
partitioner- the partitioner in use for the table queried.filter- the clustering index filter to use.- Returns:
- the newly create
DataRange.
-
keyRange
The range of partition key queried by thisDataRange.- Returns:
- the range of partition key queried by this
DataRange.
-
startKey
The start of the partition key range queried by thisDataRange.- Returns:
- the start of the partition key range queried by this
DataRange.
-
stopKey
The end of the partition key range queried by thisDataRange.- Returns:
- the end of the partition key range queried by this
DataRange.
-
startAsByteComparable
The start of the partition key range queried by thisDataRange.- Returns:
- the start of the partition key range expressed as a ByteComparable.
-
stopAsByteComparable
The end of the partition key range queried by thisDataRange.- Returns:
- the end of the partition key range expressed as a ByteComparable.
-
isNamesQuery
public boolean isNamesQuery()Whether the underlying clustering index filter is a names filter or not.- Returns:
- Whether the underlying clustering index filter is a names filter or not.
-
isPaging
public boolean isPaging()Whether the data range is for a paged request or not.- Returns:
- true if for paging, false otherwise
-
isWrapAround
public boolean isWrapAround()Whether the range queried by thisDataRangeactually wraps around.- Returns:
- whether the range queried by this
DataRangeactually wraps around.
-
contains
Whether the provided ring position is covered by thisDataRange.- Returns:
- whether the provided ring position is covered by this
DataRange.
-
isUnrestricted
Whether thisDataRangequeries everything (has no restriction neither on the partition queried, nor within the queried partition).- Returns:
- Whether this
DataRangequeries everything.
-
selectsAllPartition
public boolean selectsAllPartition() -
isReversed
public boolean isReversed()Whether the underlyingClusteringIndexFilteris reversed or not.- Returns:
- whether the underlying
ClusteringIndexFilteris reversed or not.
-
clusteringIndexFilter
The clustering index filter to use for the provided 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).
- Parameters:
key- the partition key for which we want the clustering index filter.- Returns:
- the clustering filter to use for
key.
-
forPaging
public DataRange forPaging(AbstractBounds<PartitionPosition> range, ClusteringComparator comparator, Clustering<?> lastReturned, boolean inclusive) Returns a newDataRangefor use when pagingthisrange.- Parameters:
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 ofrange(in other words,range.leftmust be the partition key for thatlastReturnedresult).inclusive- whether or not we want to include thelastReturnedin the newly returned page of results.- Returns:
- a new
DataRangesuitable for pagingthisrange given thelastRetunedresult of the previous page.
-
forSubRange
Returns a newDataRangeequivalent tothisone but restricted to the provided sub-range.- Parameters:
range- the sub-range to use for the newly returned data range. Note that assumes thatrangeis 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()).- Returns:
- a new
DataRangeusingrangeas partition key range and the clustering index filter filter fromthis.
-
toString
-
toCQLString
-
appendKeyString
-