Class ReadCommand
- All Implemented Interfaces:
Monitorable,ReadQuery
- Direct Known Subclasses:
PartitionRangeReadCommand,SinglePartitionReadCommand
This contains all the informations needed to do a local read.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumprotected static classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DataRangeprotected static final org.slf4j.Loggerstatic final IVersionedSerializer<ReadCommand> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedReadCommand(ReadCommand.Kind kind, boolean isDigestQuery, int digestVersion, boolean acceptsTransient, TableMetadata metadata, long nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, Index.QueryPlan indexQueryPlan, boolean trackWarnings, DataRange dataRange) -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected abstract voidabstract ClusteringIndexFilterThe clustering index filter this command to use for the provided key.A filter on which (non-PK) columns must be returned by the query.abstract ReadCommandcopy()Returns a copy of this command.protected abstract ReadCommandcopyAsDigestQuery(Iterable<Replica> replicas) Returns a copy of this command with isDigestQuery set to true.copyAsDigestQuery(Replica replica) Returns a copy of this command with isDigestQuery set to true.protected abstract ReadCommandcopyAsTransientQuery(Iterable<Replica> replicas) Returns a copy of this command with acceptsTransient set to true.copyAsTransientQuery(Replica replica) Returns a copy of this command with acceptsTransient set to true.createMessage(boolean trackRepairedData, Dispatcher.RequestTime requestTime) Creates a message for this command.createResponse(UnfilteredPartitionIterator iterator, org.apache.cassandra.db.RepairedDataInfo rdi) intIf the query is a digest one, the requested digest version.executeInternal(ReadExecutionController controller) Execute the query for internal queries (that is, it basically executes the query locally).executeLocally(ReadExecutionController executionController) Executes this command on the local host.Starts a new read operation.executionController(boolean trackRepairedStatus) static ReadCommandabstract longgetTimeout(TimeUnit unit) The configured timeout for this command.protected booleanhasPartitionLevelDeletions(SSTableReader sstable) protected booleanhasRequiredStatics(SSTableReader sstable) Index query plan chosen for this query.protected abstract booleanintersects(SSTableReader sstable) booleanWhether this query is a digest one or not.abstract booleanabstract booleanabstract booleanWhether the underlyingClusteringIndexFilteris reversed or not.booleanWhether this command is a single partition readbooleanisTopK()The query is a top-k query if the query has anIndex.QueryPlanthat supports top-k ordering.booleanlimits()The limits for the query.abstract StringReturn the queried token(s) for loggingvoidIf the index manager for the CFS determines that there's an applicable 2i that can be used to execute this command, call its (optional) validation method to check that nothing in this command's parameters violates the implementation specific validation rules.metadata()The metadata for the table this is a query on.name()longnowInSec()The time in seconds to use as "now" for this query.protected abstract UnfilteredPartitionIteratorqueryStorage(ColumnFamilyStore cfs, ReadExecutionController executionController) protected abstract voidrecordLatency(TableMetrics metric, long latencyNanos) Filters/Resrictions on CQL rows.protected abstract longselectionSerializedSize(int version) protected abstract voidserializeSelection(DataOutputPlus out, int version) setDigestVersion(int digestVersion) Sets the digest version, for when digest for that command is requested.Recreate the CQL string corresponding to this query.voidabstract Verbverb()protected UnfilteredPartitionIteratorwithoutPurgeableTombstones(UnfilteredPartitionIterator iterator, ColumnFamilyStore cfs, ReadExecutionController controller) abstract ReadCommandwithUpdatedLimit(DataLimits newLimits) Creates a newReadCommandinstance with new limits.Methods inherited from class org.apache.cassandra.db.monitoring.MonitorableImpl
abort, complete, creationTimeNanos, isAborted, isCompleted, isCrossNode, isInProgress, isSlow, setMonitoringTime, slowTimeoutNanos, timeoutNanosMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cassandra.db.ReadQuery
execute, getPager, isEmpty, selectsClustering, selectsFullPartition, selectsKey
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
serializer
-
dataRange
-
-
Constructor Details
-
ReadCommand
protected ReadCommand(ReadCommand.Kind kind, boolean isDigestQuery, int digestVersion, boolean acceptsTransient, TableMetadata metadata, long nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, Index.QueryPlan indexQueryPlan, boolean trackWarnings, DataRange dataRange)
-
-
Method Details
-
getCommand
-
serializeSelection
- Throws:
IOException
-
selectionSerializedSize
protected abstract long selectionSerializedSize(int version) -
isLimitedToOnePartition
public abstract boolean isLimitedToOnePartition() -
isSinglePartitionRead
public boolean isSinglePartitionRead()Whether this command is a single partition read- Returns:
- true if the command is a single partition read, false otherwise
-
isRangeRequest
public abstract boolean isRangeRequest() -
withUpdatedLimit
Creates a newReadCommandinstance with new limits.- Parameters:
newLimits- the new limits- Returns:
- a new
ReadCommandwith the updated limits
-
getTimeout
The configured timeout for this command.- Returns:
- the configured timeout for this command.
-
isDigestQuery
public boolean isDigestQuery()Whether this query is a digest one or not.- Returns:
- Whether this query is a digest query.
-
digestVersion
public int digestVersion()If the query is a digest one, the requested digest version.- Returns:
- the requested digest version if the query is a digest. Otherwise, this can return anything.
-
setDigestVersion
Sets the digest version, for when digest for that command is requested.Note that we allow setting this independently of setting the command as a digest query as this allows us to use the command as a carrier of the digest version even if we only call setIsDigestQuery on some copy of it.
- Parameters:
digestVersion- the version for the digest is this command is used for digest query..- Returns:
- this read command.
-
acceptsTransient
public boolean acceptsTransient()- Returns:
- Whether this query expects only a transient data response, or a full response
-
trackWarnings
public void trackWarnings() -
isTrackingWarnings
public boolean isTrackingWarnings() -
indexQueryPlan
Index query plan chosen for this query. Can be null.- Returns:
- index query plan chosen for this query
-
isTopK
public boolean isTopK()Description copied from interface:ReadQueryThe query is a top-k query if the query has anIndex.QueryPlanthat supports top-k ordering.- Returns:
trueif this is a top-k query
-
indexSearcher
-
clusteringIndexFilter
The 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.
- Parameters:
key- a partition key queried by this command.- Returns:
- the
ClusteringIndexFilterto use for the partition of keykey.
-
dataRange
-
copy
Returns a copy of this command.- Returns:
- a copy of this command.
-
copyAsTransientQuery
Returns a copy of this command with acceptsTransient set to true. -
copyAsTransientQuery
Returns a copy of this command with acceptsTransient set to true. -
copyAsTransientQuery
-
copyAsDigestQuery
Returns a copy of this command with isDigestQuery set to true. -
copyAsDigestQuery
Returns a copy of this command with isDigestQuery set to true. -
copyAsDigestQuery
-
queryStorage
protected abstract UnfilteredPartitionIterator queryStorage(ColumnFamilyStore cfs, ReadExecutionController executionController) -
isReversed
public abstract boolean isReversed()Whether the underlyingClusteringIndexFilteris reversed or not.- Returns:
- whether the underlying
ClusteringIndexFilteris reversed or not.
-
createResponse
public ReadResponse createResponse(UnfilteredPartitionIterator iterator, org.apache.cassandra.db.RepairedDataInfo rdi) -
createEmptyResponse
-
maybeValidateIndex
public void maybeValidateIndex()If the index manager for the CFS determines that there's an applicable 2i that can be used to execute this command, call its (optional) validation method to check that nothing in this command's parameters violates the implementation specific validation rules. -
executeLocally
Executes this command on the local host.- Parameters:
executionController- the execution controller spanning this command- Returns:
- an iterator over the result of executing this command locally.
-
recordLatency
-
executionController
-
executionController
Description copied from interface:ReadQueryStarts a new read operation.This must be called before
ReadQuery.executeInternal(org.apache.cassandra.db.ReadExecutionController)and passed to it to protect the read. The returned object must be closed on all path and it is thus strongly advised to use it in a try-with-ressource construction.- Returns:
- a newly started execution controller for this
ReadQuery.
-
createMessage
public Message<ReadCommand> createMessage(boolean trackRepairedData, Dispatcher.RequestTime requestTime) Creates a message for this command. -
intersects
-
hasRequiredStatics
-
hasPartitionLevelDeletions
-
verb
-
appendCQLWhereClause
-
withoutPurgeableTombstones
protected UnfilteredPartitionIterator withoutPurgeableTombstones(UnfilteredPartitionIterator iterator, ColumnFamilyStore cfs, ReadExecutionController controller) -
loggableTokens
Return the queried token(s) for logging -
name
- Specified by:
namein interfaceMonitorable
-
metadata
Description copied from interface:ReadQueryThe metadata for the table this is a query on. -
executeInternal
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
Description copied from interface:ReadQueryThe limits for the query. -
nowInSec
public long 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
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
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
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.
-