public abstract class ReadCommand extends MonitorableImpl
This contains all the informations needed to do a local read.
Modifier and Type | Class and Description |
---|---|
protected class |
ReadCommand.CheckForAbort |
protected static class |
ReadCommand.Kind |
protected static class |
ReadCommand.SelectionDeserializer |
static class |
ReadCommand.Serializer |
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
logger |
static IVersionedSerializer<ReadCommand> |
serializer |
Modifier | Constructor and Description |
---|---|
protected |
ReadCommand(ReadCommand.Kind kind,
boolean isDigestQuery,
int digestVersion,
boolean acceptsTransient,
TableMetadata metadata,
int nowInSec,
ColumnFilter columnFilter,
RowFilter rowFilter,
DataLimits limits,
IndexMetadata index) |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptsTransient() |
protected abstract void |
appendCQLWhereClause(java.lang.StringBuilder sb) |
abstract ClusteringIndexFilter |
clusteringIndexFilter(DecoratedKey key)
The clustering index filter this command to use for the provided key.
|
ColumnFilter |
columnFilter()
A filter on which (non-PK) columns must be returned by the query.
|
abstract ReadCommand |
copy()
Returns a copy of this command.
|
protected abstract ReadCommand |
copyAsDigestQuery() |
ReadCommand |
copyAsDigestQuery(java.lang.Iterable<Replica> replicas)
Returns a copy of this command with isDigestQuery set to true.
|
ReadCommand |
copyAsDigestQuery(Replica replica)
Returns a copy of this command with isDigestQuery set to true.
|
protected abstract ReadCommand |
copyAsTransientQuery() |
ReadCommand |
copyAsTransientQuery(java.lang.Iterable<Replica> replicas)
Returns a copy of this command with acceptsTransient set to true.
|
ReadCommand |
copyAsTransientQuery(Replica replica)
Returns a copy of this command with acceptsTransient set to true.
|
Message<ReadCommand> |
createMessage(boolean trackRepairedData)
Creates a message for this command.
|
ReadResponse |
createResponse(UnfilteredPartitionIterator iterator,
org.apache.cassandra.db.RepairedDataInfo rdi) |
int |
digestVersion()
If the query is a digest one, the requested digest version.
|
PartitionIterator |
executeInternal(ReadExecutionController controller)
Execute the query for internal queries (that is, it basically executes the query locally).
|
UnfilteredPartitionIterator |
executeLocally(ReadExecutionController executionController)
Executes this command on the local host.
|
ReadExecutionController |
executionController()
Starts a new read operation.
|
ReadExecutionController |
executionController(boolean trackRepairedStatus) |
Index |
getIndex(ColumnFamilyStore cfs) |
abstract long |
getTimeout(java.util.concurrent.TimeUnit unit)
The configured timeout for this command.
|
IndexMetadata |
indexMetadata()
Index (metadata) chosen for this query.
|
boolean |
isDigestQuery()
Whether this query is a digest one or not.
|
abstract boolean |
isLimitedToOnePartition() |
abstract boolean |
isRangeRequest() |
abstract boolean |
isReversed()
Whether the underlying
ClusteringIndexFilter is reversed or not. |
DataLimits |
limits()
The limits for the query.
|
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.
|
TableMetadata |
metadata()
The metadata for the table this is a query on.
|
java.lang.String |
name() |
int |
nowInSec()
The time in seconds to use as "now" for this query.
|
protected abstract UnfilteredPartitionIterator |
queryStorage(ColumnFamilyStore cfs,
ReadExecutionController executionController) |
protected abstract void |
recordLatency(TableMetrics metric,
long latencyNanos) |
RowFilter |
rowFilter()
Filters/Resrictions on CQL rows.
|
protected abstract long |
selectionSerializedSize(int version) |
protected abstract void |
serializeSelection(DataOutputPlus out,
int version) |
ReadCommand |
setDigestVersion(int digestVersion)
Sets the digest version, for when digest for that command is requested.
|
java.lang.String |
toCQLString()
Recreate the CQL string corresponding to this query.
|
abstract Verb |
verb() |
protected UnfilteredPartitionIterator |
withoutPurgeableTombstones(UnfilteredPartitionIterator iterator,
ColumnFamilyStore cfs,
ReadExecutionController controller) |
protected UnfilteredPartitionIterator |
withStateTracking(UnfilteredPartitionIterator iter) |
abstract ReadCommand |
withUpdatedLimit(DataLimits newLimits)
Creates a new
ReadCommand instance with new limits. |
abort, complete, creationTimeNanos, isAborted, isCompleted, isCrossNode, isInProgress, isSlow, setMonitoringTime, slowTimeoutNanos, timeoutNanos
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
empty, execute, getPager, isEmpty, selectsClustering, selectsFullPartition, selectsKey
protected static final org.slf4j.Logger logger
public static final IVersionedSerializer<ReadCommand> serializer
protected ReadCommand(ReadCommand.Kind kind, boolean isDigestQuery, int digestVersion, boolean acceptsTransient, TableMetadata metadata, int nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, IndexMetadata index)
protected abstract void serializeSelection(DataOutputPlus out, int version) throws java.io.IOException
java.io.IOException
protected abstract long selectionSerializedSize(int version)
public abstract boolean isLimitedToOnePartition()
public abstract boolean isRangeRequest()
public abstract ReadCommand withUpdatedLimit(DataLimits newLimits)
ReadCommand
instance with new limits.newLimits
- the new limitsReadCommand
with the updated limitspublic abstract long getTimeout(java.util.concurrent.TimeUnit unit)
public boolean isDigestQuery()
public int digestVersion()
public ReadCommand setDigestVersion(int digestVersion)
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.
digestVersion
- the version for the digest is this command is used for digest query..public boolean acceptsTransient()
@Nullable public IndexMetadata indexMetadata()
public abstract ClusteringIndexFilter clusteringIndexFilter(DecoratedKey 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.
key
- a partition key queried by this command.ClusteringIndexFilter
to use for the partition of key key
.public abstract ReadCommand copy()
public ReadCommand copyAsTransientQuery(Replica replica)
public ReadCommand copyAsTransientQuery(java.lang.Iterable<Replica> replicas)
protected abstract ReadCommand copyAsTransientQuery()
public ReadCommand copyAsDigestQuery(Replica replica)
public ReadCommand copyAsDigestQuery(java.lang.Iterable<Replica> replicas)
protected abstract ReadCommand copyAsDigestQuery()
protected abstract UnfilteredPartitionIterator queryStorage(ColumnFamilyStore cfs, ReadExecutionController executionController)
public abstract boolean isReversed()
ClusteringIndexFilter
is reversed or not.ClusteringIndexFilter
is reversed or not.public ReadResponse createResponse(UnfilteredPartitionIterator iterator, org.apache.cassandra.db.RepairedDataInfo rdi)
public Index getIndex(ColumnFamilyStore cfs)
public void maybeValidateIndex()
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
executionController
- the execution controller spanning this commandprotected abstract void recordLatency(TableMetrics metric, long latencyNanos)
public ReadExecutionController executionController(boolean trackRepairedStatus)
public ReadExecutionController executionController()
ReadQuery
This must be called before executeInternal
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.
ReadQuery
.protected UnfilteredPartitionIterator withStateTracking(UnfilteredPartitionIterator iter)
public Message<ReadCommand> createMessage(boolean trackRepairedData)
public abstract Verb verb()
protected abstract void appendCQLWhereClause(java.lang.StringBuilder sb)
protected UnfilteredPartitionIterator withoutPurgeableTombstones(UnfilteredPartitionIterator iterator, ColumnFamilyStore cfs, ReadExecutionController controller)
public java.lang.String toCQLString()
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.
public java.lang.String name()
name
in interface Monitorable
public TableMetadata metadata()
ReadQuery
public PartitionIterator executeInternal(ReadExecutionController controller)
ReadQuery
executeInternal
in interface ReadQuery
controller
- the ReadExecutionController
protecting the read.public DataLimits limits()
ReadQuery
public int nowInSec()
ReadQuery
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).
public RowFilter rowFilter()
ReadQuery
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.
public ColumnFilter columnFilter()
ReadQuery
columnFilter
in interface ReadQuery
Copyright © 2009-2021 The Apache Software Foundation