Class PartitionRangeReadCommand
- java.lang.Object
-
- org.apache.cassandra.db.monitoring.MonitorableImpl
-
- org.apache.cassandra.db.ReadCommand
-
- org.apache.cassandra.db.PartitionRangeReadCommand
-
- All Implemented Interfaces:
Monitorable,PartitionRangeReadQuery,ReadQuery
- Direct Known Subclasses:
PartitionRangeReadCommand.VirtualTablePartitionRangeReadCommand
public class PartitionRangeReadCommand extends ReadCommand implements PartitionRangeReadQuery
A read command that selects a (part of a) range of partitions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPartitionRangeReadCommand.VirtualTablePartitionRangeReadCommand-
Nested classes/interfaces inherited from class org.apache.cassandra.db.ReadCommand
ReadCommand.CheckForAbort, ReadCommand.Kind, ReadCommand.SelectionDeserializer, ReadCommand.Serializer
-
-
Field Summary
Fields Modifier and Type Field Description protected DataRangedataRangeprotected static ReadCommand.SelectionDeserializerselectionDeserializer-
Fields inherited from class org.apache.cassandra.db.ReadCommand
logger, serializer
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPartitionRangeReadCommand(boolean isDigest, int digestVersion, boolean acceptsTransient, TableMetadata metadata, int nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DataRange dataRange, IndexMetadata index, boolean trackWarnings)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PartitionRangeReadCommandallDataRead(TableMetadata metadata, int nowInSec)Creates a new read command that query all the data in the table.protected voidappendCQLWhereClause(java.lang.StringBuilder sb)ClusteringIndexFilterclusteringIndexFilter(DecoratedKey key)The clustering index filter this command to use for the provided key.ColumnFiltercolumnFilter()A filter on which (non-PK) columns must be returned by the query.PartitionRangeReadCommandcopy()Returns a copy of this command.protected PartitionRangeReadCommandcopyAsDigestQuery()protected PartitionRangeReadCommandcopyAsTransientQuery()static PartitionRangeReadCommandcreate(TableMetadata metadata, int nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DataRange dataRange)DataRangedataRange()PartitionIteratorexecute(ConsistencyLevel consistency, ClientState state, Dispatcher.RequestTime requestTime)Executes the query at the provided consistency level.PartitionIteratorexecuteInternal(ReadExecutionController controller)Execute the query for internal queries (that is, it basically executes the query locally).PartitionRangeReadCommandforSubRange(AbstractBounds<PartitionPosition> range, boolean isRangeContinuation)Returns an equivalent command but that only queries data within the provided range.longgetTimeout(java.util.concurrent.TimeUnit unit)The configured timeout for this command.booleanisLimitedToOnePartition()booleanisNamesQuery()booleanisRangeRequest()booleanisReversed()Whether the underlyingClusteringIndexFilteris reversed or not.DataLimitslimits()The limits for the query.java.lang.StringloggableTokens()Return the queried token(s) for loggingTableMetadatametadata()The metadata for the table this is a query on.intnowInSec()The time in seconds to use as "now" for this query.PartitionIteratorpostReconciliationProcessing(PartitionIterator result)Allow to post-process the result of the query after it has been reconciled on the coordinator but before it is passed to the CQL layer to return the ResultSet.UnfilteredPartitionIteratorqueryStorage(ColumnFamilyStore cfs, ReadExecutionController controller)protected voidrecordLatency(TableMetrics metric, long latencyNanos)RowFilterrowFilter()Filters/Resrictions on CQL rows.protected longselectionSerializedSize(int version)protected voidserializeSelection(DataOutputPlus out, int version)java.lang.StringtoCQLString()Recreate the CQL string corresponding to this query.java.lang.StringtoString()Verbverb()PartitionRangeReadCommandwithUpdatedLimit(DataLimits newLimits)Creates a newReadCommandinstance with new limits.PartitionRangeReadCommandwithUpdatedLimitsAndDataRange(DataLimits newLimits, DataRange newDataRange)Creates a newPartitionRangeReadQuerywith the updated limits and data range.-
Methods inherited from class org.apache.cassandra.db.ReadCommand
acceptsTransient, copyAsDigestQuery, copyAsDigestQuery, copyAsTransientQuery, copyAsTransientQuery, createEmptyResponse, createMessage, createResponse, digestVersion, executeLocally, executionController, executionController, getCommand, getIndex, indexMetadata, isDigestQuery, isSinglePartitionRead, isTrackingWarnings, maybeValidateIndex, name, setDigestVersion, trackWarnings, withoutPurgeableTombstones, withStateTracking
-
Methods inherited from class org.apache.cassandra.db.monitoring.MonitorableImpl
abort, complete, creationTimeNanos, isAborted, isCompleted, isCrossNode, isInProgress, isSlow, setMonitoringTime, slowTimeoutNanos, timeoutNanos
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.db.PartitionRangeReadQuery
getPager, selectsClustering, selectsFullPartition, selectsKey
-
Methods inherited from interface org.apache.cassandra.db.ReadQuery
columnFilter, executeInternal, executeLocally, executionController, isEmpty, limits, maybeValidateIndex, metadata, nowInSec, rowFilter, trackWarnings
-
-
-
-
Field Detail
-
selectionDeserializer
protected static final ReadCommand.SelectionDeserializer selectionDeserializer
-
dataRange
protected final DataRange dataRange
-
-
Constructor Detail
-
PartitionRangeReadCommand
protected PartitionRangeReadCommand(boolean isDigest, int digestVersion, boolean acceptsTransient, TableMetadata metadata, int nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DataRange dataRange, IndexMetadata index, boolean trackWarnings)
-
-
Method Detail
-
create
public static PartitionRangeReadCommand create(TableMetadata metadata, int nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DataRange dataRange)
-
allDataRead
public static PartitionRangeReadCommand allDataRead(TableMetadata metadata, int nowInSec)
Creates a new read command that query all the data in the table.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.- Returns:
- a newly created read command that queries everything in the table.
-
dataRange
public DataRange dataRange()
- Specified by:
dataRangein interfacePartitionRangeReadQuery
-
clusteringIndexFilter
public ClusteringIndexFilter clusteringIndexFilter(DecoratedKey key)
Description copied from class:ReadCommandThe clustering index filter this command to use for the provided key.Note that that method should only be called on a key actually queried by this command and in practice, this will almost always return the same filter, but for the sake of paging, the filter on the first key of a range command might be slightly different.
- Specified by:
clusteringIndexFilterin classReadCommand- Parameters:
key- a partition key queried by this command.- Returns:
- the
ClusteringIndexFilterto use for the partition of keykey.
-
isNamesQuery
public boolean isNamesQuery()
-
forSubRange
public PartitionRangeReadCommand forSubRange(AbstractBounds<PartitionPosition> range, boolean isRangeContinuation)
Returns an equivalent command but that only queries data within the provided range.- Parameters:
range- the sub-range to restrict the command to. This method assumes that this is a proper sub-range of the command this is applied to.isRangeContinuation- whetherrangeis a direct continuation of whatever previous range we have queried. This matters for theDataLimitsthat may contain states when we do paging and in the context of parallel queries: that state only make sense if the range queried is indeed the follow-up of whatever range we've previously query (that yield said state). In practice this means that ranges for whichisRangeContinuationis false may have to be slightly pessimistic when counting data and may include a little bit than necessary, and this should be dealt with post-query (in the case ofStorageProxy.getRangeSlice(), which uses this method for replica queries, this is dealt with by re-counting results on the coordinator). Note that if this is the first range we queried, then theDataLimitswill have not state and the value of this parameter doesn't matter.
-
copy
public PartitionRangeReadCommand copy()
Description copied from class:ReadCommandReturns a copy of this command.- Specified by:
copyin classReadCommand- Returns:
- a copy of this command.
-
copyAsDigestQuery
protected PartitionRangeReadCommand copyAsDigestQuery()
- Specified by:
copyAsDigestQueryin classReadCommand
-
copyAsTransientQuery
protected PartitionRangeReadCommand copyAsTransientQuery()
- Specified by:
copyAsTransientQueryin classReadCommand
-
withUpdatedLimit
public PartitionRangeReadCommand withUpdatedLimit(DataLimits newLimits)
Description copied from class:ReadCommandCreates a newReadCommandinstance with new limits.- Specified by:
withUpdatedLimitin interfacePartitionRangeReadQuery- Specified by:
withUpdatedLimitin classReadCommand- Parameters:
newLimits- the new limits- Returns:
- a new
ReadCommandwith the updated limits
-
withUpdatedLimitsAndDataRange
public PartitionRangeReadCommand withUpdatedLimitsAndDataRange(DataLimits newLimits, DataRange newDataRange)
Description copied from interface:PartitionRangeReadQueryCreates a newPartitionRangeReadQuerywith the updated limits and data range.- Specified by:
withUpdatedLimitsAndDataRangein interfacePartitionRangeReadQuery- Parameters:
newLimits- the new limits- Returns:
- the new
PartitionRangeReadQuery
-
getTimeout
public long getTimeout(java.util.concurrent.TimeUnit unit)
Description copied from class:ReadCommandThe configured timeout for this command.- Specified by:
getTimeoutin classReadCommand- Returns:
- the configured timeout for this command.
-
isReversed
public boolean isReversed()
Description copied from class:ReadCommandWhether the underlyingClusteringIndexFilteris reversed or not.- Specified by:
isReversedin classReadCommand- Returns:
- whether the underlying
ClusteringIndexFilteris reversed or not.
-
execute
public PartitionIterator execute(ConsistencyLevel consistency, ClientState state, Dispatcher.RequestTime requestTime) throws RequestExecutionException
Description copied from interface:ReadQueryExecutes the query at the provided consistency level.- Specified by:
executein interfaceReadQuery- Parameters:
consistency- the consistency level to achieve for the query.state- client state- Returns:
- the result of the query.
- Throws:
RequestExecutionException
-
recordLatency
protected void recordLatency(TableMetrics metric, long latencyNanos)
- Specified by:
recordLatencyin classReadCommand
-
queryStorage
public UnfilteredPartitionIterator queryStorage(ColumnFamilyStore cfs, ReadExecutionController controller)
- Specified by:
queryStoragein classReadCommand
-
verb
public Verb verb()
- Specified by:
verbin classReadCommand
-
appendCQLWhereClause
protected void appendCQLWhereClause(java.lang.StringBuilder sb)
- Specified by:
appendCQLWhereClausein classReadCommand
-
loggableTokens
public java.lang.String loggableTokens()
Description copied from class:ReadCommandReturn the queried token(s) for logging- Specified by:
loggableTokensin classReadCommand
-
postReconciliationProcessing
public PartitionIterator postReconciliationProcessing(PartitionIterator result)
Allow to post-process the result of the query after it has been reconciled on the coordinator but before it is passed to the CQL layer to return the ResultSet. See CASSANDRA-8717 for why this exists.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
serializeSelection
protected void serializeSelection(DataOutputPlus out, int version) throws java.io.IOException
- Specified by:
serializeSelectionin classReadCommand- Throws:
java.io.IOException
-
selectionSerializedSize
protected long selectionSerializedSize(int version)
- Specified by:
selectionSerializedSizein classReadCommand
-
isLimitedToOnePartition
public boolean isLimitedToOnePartition()
- Specified by:
isLimitedToOnePartitionin classReadCommand
-
isRangeRequest
public boolean isRangeRequest()
- Specified by:
isRangeRequestin classReadCommand
-
metadata
public TableMetadata metadata()
Description copied from interface:ReadQueryThe metadata for the table this is a query on.
-
executeInternal
public PartitionIterator executeInternal(ReadExecutionController controller)
Description copied from interface:ReadQueryExecute the query for internal queries (that is, it basically executes the query locally).- Specified by:
executeInternalin interfaceReadQuery- Parameters:
controller- theReadExecutionControllerprotecting the read.- Returns:
- the result of the query.
-
limits
public DataLimits limits()
Description copied from interface:ReadQueryThe limits for the query.
-
nowInSec
public int nowInSec()
Description copied from interface:ReadQueryThe time in seconds to use as "now" for this query.We use the same time as "now" for the whole query to avoid considering different values as expired during the query, which would be buggy (would throw of counting amongst other things).
-
rowFilter
public RowFilter rowFilter()
Description copied from interface:ReadQueryFilters/Resrictions on CQL rows.This contains the restrictions that are not directly handled by the
ClusteringIndexFilter. More specifically, this includes any non-PK column restrictions and can include some PK columns restrictions when those can't be satisfied entirely by the clustering index filter (because not all clustering columns have been restricted for instance). If there is 2ndary indexes on the table, one of this restriction might be handled by a 2ndary index.
-
columnFilter
public ColumnFilter columnFilter()
Description copied from interface:ReadQueryA filter on which (non-PK) columns must be returned by the query.- Specified by:
columnFilterin interfaceReadQuery- Returns:
- which columns must be fetched by this query.
-
toCQLString
public java.lang.String toCQLString()
Recreate the CQL string corresponding to this query.Note that in general the returned string will not be exactly the original user string, first because there isn't always a single syntax for a given query, but also because we don't have all the information needed (we know the non-PK columns queried but not the PK ones as internally we query them all). So this shouldn't be relied too strongly, but this should be good enough for debugging purpose which is what this is for.
-
-