Class SinglePartitionReadCommand
- All Implemented Interfaces:
Monitorable,ReadQuery,SinglePartitionReadQuery
- Direct Known Subclasses:
SinglePartitionReadCommand.VirtualTableSinglePartitionReadCommand
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classGroups multiple single partition read commands.static classstatic classNested classes/interfaces inherited from class org.apache.cassandra.db.ReadCommand
ReadCommand.Kind, ReadCommand.SelectionDeserializer, ReadCommand.Serializer -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ClusteringIndexFilterprotected final DecoratedKeyprotected static final ReadCommand.SelectionDeserializerFields inherited from class org.apache.cassandra.db.ReadCommand
dataRange, logger, serializer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSinglePartitionReadCommand(boolean isDigest, int digestVersion, boolean acceptsTransient, TableMetadata metadata, long nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, Index.QueryPlan indexQueryPlan, boolean trackWarnings, DataRange dataRange) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThe clustering index filter this command to use for the provided key.A filter on which (non-PK) columns must be returned by the query.copy()Returns a copy of this command.protected SinglePartitionReadCommandprotected SinglePartitionReadCommandstatic SinglePartitionReadCommandcreate(TableMetadata metadata, long nowInSec, ByteBuffer key, Slices slices) Creates a new single partition slice command for the provided slices.static SinglePartitionReadCommandcreate(TableMetadata metadata, long nowInSec, DecoratedKey key, NavigableSet<Clustering<?>> names) Creates a new single partition name command for the provided rows.static SinglePartitionReadCommandcreate(TableMetadata metadata, long nowInSec, DecoratedKey key, Clustering<?> name) Creates a new single partition name command for the provided row.static SinglePartitionReadCommandcreate(TableMetadata metadata, long nowInSec, DecoratedKey key, ColumnFilter columnFilter, ClusteringIndexFilter filter) Creates a new read command on a single partition.static SinglePartitionReadCommandcreate(TableMetadata metadata, long nowInSec, DecoratedKey key, Slice slice) Creates a new single partition slice command for the provided single slice.static SinglePartitionReadCommandcreate(TableMetadata metadata, long nowInSec, DecoratedKey key, Slices slices) Creates a new single partition slice command for the provided slices.static SinglePartitionReadCommandcreate(TableMetadata metadata, long nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter) Creates a new read command on a single partition.static SinglePartitionReadCommandcreate(TableMetadata metadata, long nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, Index.QueryPlan indexQueryPlan) Creates a new read command on a single partition.execute(ConsistencyLevel consistency, ClientState state, Dispatcher.RequestTime requestTime) Executes the query at the provided consistency level.executeInternal(ReadExecutionController controller) Execute the query for internal queries (that is, it basically executes the query locally).forPaging(Clustering<?> lastReturned, DataLimits limits) Returns a newSinglePartitionReadQuerysuitable to paging from the last returned row.static SinglePartitionReadCommandfullPartitionRead(TableMetadata metadata, long nowInSec, ByteBuffer key) Creates a new read command that queries a single partition in its entirety.static SinglePartitionReadCommandfullPartitionRead(TableMetadata metadata, long nowInSec, DecoratedKey key) Creates a new read command that queries a single partition in its entirety.longgetTimeout(TimeUnit unit) The configured timeout for this command.protected booleanintersects(SSTableReader sstable) booleanbooleanbooleanWhether the underlyingClusteringIndexFilteris reversed or not.limits()The limits for the query.Return the queried token(s) for loggingmetadata()The metadata for the table this is a query on.longnowInSec()The time in seconds to use as "now" for this query.Returns the key of the partition queried by thisReadQueryqueryMemtableAndDisk(ColumnFamilyStore cfs, ColumnFamilyStore.ViewFragment view, Function<CellSourceIdentifier, Transformation<BaseRowIterator<?>>> rowTransformer, ReadExecutionController executionController) queryMemtableAndDisk(ColumnFamilyStore cfs, ReadExecutionController executionController) Queries both memtable and sstables to fetch the result of this query.protected UnfilteredPartitionIteratorqueryStorage(ColumnFamilyStore cfs, ReadExecutionController executionController) protected voidrecordLatency(TableMetrics metric, long latencyNanos) Filters/Resrictions on CQL rows.protected longselectionSerializedSize(int version) booleanChecks if thisReadQueryselects full partitions, that is it has no filtering on clustering or regular columns.protected voidserializeSelection(DataOutputPlus out, int version) Recreate the CQL string corresponding to this query.toString()verb()withUpdatedLimit(DataLimits newLimits) Creates a newReadCommandinstance with new limits.Methods inherited from class org.apache.cassandra.db.ReadCommand
acceptsTransient, copyAsDigestQuery, copyAsDigestQuery, copyAsTransientQuery, copyAsTransientQuery, createEmptyResponse, createMessage, createResponse, dataRange, digestVersion, executeLocally, executionController, executionController, getCommand, hasPartitionLevelDeletions, hasRequiredStatics, indexQueryPlan, indexSearcher, isDigestQuery, isSinglePartitionRead, isTopK, isTrackingWarnings, maybeValidateIndex, name, setDigestVersion, trackWarnings, withoutPurgeableTombstonesMethods 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, wait, wait, waitMethods inherited from interface org.apache.cassandra.db.ReadQuery
columnFilter, dataRange, executeInternal, executeLocally, executionController, isEmpty, isTopK, limits, maybeValidateIndex, metadata, nowInSec, rowFilter, trackWarningsMethods inherited from interface org.apache.cassandra.db.SinglePartitionReadQuery
getPager, selectsClustering, selectsKey
-
Field Details
-
selectionDeserializer
-
partitionKey
-
clusteringIndexFilter
-
-
Constructor Details
-
SinglePartitionReadCommand
protected SinglePartitionReadCommand(boolean isDigest, int digestVersion, boolean acceptsTransient, TableMetadata metadata, long nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, Index.QueryPlan indexQueryPlan, boolean trackWarnings, DataRange dataRange)
-
-
Method Details
-
create
public static SinglePartitionReadCommand create(TableMetadata metadata, long nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, Index.QueryPlan indexQueryPlan) Creates a new read command on a single partition.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.columnFilter- the column filter to use for the query.rowFilter- the row filter to use for the query.limits- the limits to use for the query.partitionKey- the partition key for the partition to query.clusteringIndexFilter- the clustering index filter to use for the query.indexQueryPlan- explicitly specified index to use for the query- Returns:
- a newly created read command.
-
create
public static SinglePartitionReadCommand create(TableMetadata metadata, long nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter) Creates a new read command on a single partition.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.columnFilter- the column filter to use for the query.rowFilter- the row filter to use for the query.limits- the limits to use for the query.partitionKey- the partition key for the partition to query.clusteringIndexFilter- the clustering index filter to use for the query.- Returns:
- a newly created read command.
-
create
public static SinglePartitionReadCommand create(TableMetadata metadata, long nowInSec, DecoratedKey key, ColumnFilter columnFilter, ClusteringIndexFilter filter) Creates a new read command on a single partition.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.key- the partition key for the partition to query.columnFilter- the column filter to use for the query.filter- the clustering index filter to use for the query.- Returns:
- a newly created read command. The returned command will use no row filter and have no limits.
-
fullPartitionRead
public static SinglePartitionReadCommand fullPartitionRead(TableMetadata metadata, long nowInSec, DecoratedKey key) Creates a new read command that queries a single partition in its entirety.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.key- the partition key for the partition to query.- Returns:
- a newly created read command that queries all the rows of
key.
-
fullPartitionRead
public static SinglePartitionReadCommand fullPartitionRead(TableMetadata metadata, long nowInSec, ByteBuffer key) Creates a new read command that queries a single partition in its entirety.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.key- the partition key for the partition to query.- Returns:
- a newly created read command that queries all the rows of
key.
-
create
public static SinglePartitionReadCommand create(TableMetadata metadata, long nowInSec, DecoratedKey key, Slice slice) Creates a new single partition slice command for the provided single slice.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.key- the partition key for the partition to query.slice- the slice of rows to query.- Returns:
- a newly created read command that queries
sliceinkey. The returned query will query every columns for the table (without limit or row filtering) and be in forward order.
-
create
public static SinglePartitionReadCommand create(TableMetadata metadata, long nowInSec, DecoratedKey key, Slices slices) Creates a new single partition slice command for the provided slices.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.key- the partition key for the partition to query.slices- the slices of rows to query.- Returns:
- a newly created read command that queries the
slicesinkey. The returned query will query every columns for the table (without limit or row filtering) and be in forward order.
-
create
public static SinglePartitionReadCommand create(TableMetadata metadata, long nowInSec, ByteBuffer key, Slices slices) Creates a new single partition slice command for the provided slices.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.key- the partition key for the partition to query.slices- the slices of rows to query.- Returns:
- a newly created read command that queries the
slicesinkey. The returned query will query every columns for the table (without limit or row filtering) and be in forward order.
-
create
public static SinglePartitionReadCommand create(TableMetadata metadata, long nowInSec, DecoratedKey key, Clustering<?> name) Creates a new single partition name command for the provided row.- Parameters:
metadata- the table to query.nowInSec- the time in seconds to use are "now" for this query.key- the partition key for the partition to query.name- the clustering for the row to query.- Returns:
- a newly created read command that queries
nameinkey. The returned query will query every columns (without limit or row filtering).
-
copy
Description copied from class:ReadCommandReturns a copy of this command.- Specified by:
copyin classReadCommand- Returns:
- a copy of this command.
-
copyAsDigestQuery
- Specified by:
copyAsDigestQueryin classReadCommand
-
copyAsTransientQuery
- Specified by:
copyAsTransientQueryin classReadCommand
-
withUpdatedLimit
Description copied from class:ReadCommandCreates a newReadCommandinstance with new limits.- Specified by:
withUpdatedLimitin interfaceSinglePartitionReadQuery- Specified by:
withUpdatedLimitin classReadCommand- Parameters:
newLimits- the new limits- Returns:
- a new
ReadCommandwith the updated limits
-
partitionKey
Description copied from interface:SinglePartitionReadQueryReturns the key of the partition queried by thisReadQuery- Specified by:
partitionKeyin interfaceSinglePartitionReadQuery- Returns:
- the key of the partition queried
-
clusteringIndexFilter
- Specified by:
clusteringIndexFilterin interfaceSinglePartitionReadQuery
-
clusteringIndexFilter
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.
-
getTimeout
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.
-
forPaging
Description copied from interface:SinglePartitionReadQueryReturns a newSinglePartitionReadQuerysuitable to paging from the last returned row.- Specified by:
forPagingin interfaceSinglePartitionReadQuery- Parameters:
lastReturned- the last row returned by the previous page. The newly created query will only query row that comes after this (in query order). This can benullif this is the first page.limits- the limits to use for the page to query.- Returns:
- the newly create query.
-
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 staterequestTime- request enqueue / and start times- Returns:
- the result of the query.
- Throws:
RequestExecutionException
-
recordLatency
- Specified by:
recordLatencyin classReadCommand
-
queryStorage
protected UnfilteredPartitionIterator queryStorage(ColumnFamilyStore cfs, ReadExecutionController executionController) - Specified by:
queryStoragein classReadCommand
-
queryMemtableAndDisk
public UnfilteredRowIterator queryMemtableAndDisk(ColumnFamilyStore cfs, ReadExecutionController executionController) Queries both memtable and sstables to fetch the result of this query.Please note that this method: 1) does not check the row cache. 2) does not apply the query limit, nor the row filter (and so ignore 2ndary indexes). Those are applied in
ReadCommand.executeLocally(org.apache.cassandra.db.ReadExecutionController). 3) does not record some of the read metrics (latency, scanned cells histograms) nor throws TombstoneOverwhelmingException. It is publicly exposed because there is a few places where that is exactly what we want, but it should be used only where you know you don't need thoses things.Also note that one must have created a
ReadExecutionControlleron the queried table and we require it as a parameter to enforce that fact, even though it's not explicitlly used by the method. -
queryMemtableAndDisk
public UnfilteredRowIterator queryMemtableAndDisk(ColumnFamilyStore cfs, ColumnFamilyStore.ViewFragment view, Function<CellSourceIdentifier, Transformation<BaseRowIterator<?>>> rowTransformer, ReadExecutionController executionController) -
intersects
- Specified by:
intersectsin classReadCommand
-
selectsFullPartition
public boolean selectsFullPartition()Description copied from interface:ReadQueryChecks if thisReadQueryselects full partitions, that is it has no filtering on clustering or regular columns.- Specified by:
selectsFullPartitionin interfaceReadQuery- Returns:
trueif thisReadQueryselects full partitions,falseotherwise.
-
toString
-
verb
- Specified by:
verbin classReadCommand
-
appendCQLWhereClause
- Specified by:
appendCQLWhereClausein classReadCommand
-
loggableTokens
Description copied from class:ReadCommandReturn the queried token(s) for logging- Specified by:
loggableTokensin classReadCommand
-
serializeSelection
- Specified by:
serializeSelectionin classReadCommand- Throws:
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
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.
-