public class SinglePartitionReadCommand extends ReadCommand implements SinglePartitionReadQuery
Modifier and Type | Class and Description |
---|---|
static class |
SinglePartitionReadCommand.Group
Groups multiple single partition read commands.
|
static class |
SinglePartitionReadCommand.VirtualTableGroup |
static class |
SinglePartitionReadCommand.VirtualTableSinglePartitionReadCommand |
ReadCommand.CheckForAbort, ReadCommand.Kind, ReadCommand.SelectionDeserializer, ReadCommand.Serializer
Modifier and Type | Field and Description |
---|---|
protected ClusteringIndexFilter |
clusteringIndexFilter |
protected DecoratedKey |
partitionKey |
protected static ReadCommand.SelectionDeserializer |
selectionDeserializer |
logger, serializer
Modifier | Constructor and Description |
---|---|
protected |
SinglePartitionReadCommand(boolean isDigest,
int digestVersion,
boolean acceptsTransient,
TableMetadata metadata,
int nowInSec,
ColumnFilter columnFilter,
RowFilter rowFilter,
DataLimits limits,
DecoratedKey partitionKey,
ClusteringIndexFilter clusteringIndexFilter,
IndexMetadata index,
boolean trackWarnings) |
Modifier and Type | Method and Description |
---|---|
protected void |
appendCQLWhereClause(java.lang.StringBuilder sb) |
ClusteringIndexFilter |
clusteringIndexFilter() |
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.
|
SinglePartitionReadCommand |
copy()
Returns a copy of this command.
|
protected SinglePartitionReadCommand |
copyAsDigestQuery() |
protected SinglePartitionReadCommand |
copyAsTransientQuery() |
static SinglePartitionReadCommand |
create(TableMetadata metadata,
int nowInSec,
java.nio.ByteBuffer key,
Slices slices)
Creates a new single partition slice command for the provided slices.
|
static SinglePartitionReadCommand |
create(TableMetadata metadata,
int nowInSec,
ColumnFilter columnFilter,
RowFilter rowFilter,
DataLimits limits,
DecoratedKey partitionKey,
ClusteringIndexFilter clusteringIndexFilter)
Creates a new read command on a single partition.
|
static SinglePartitionReadCommand |
create(TableMetadata metadata,
int nowInSec,
ColumnFilter columnFilter,
RowFilter rowFilter,
DataLimits limits,
DecoratedKey partitionKey,
ClusteringIndexFilter clusteringIndexFilter,
IndexMetadata indexMetadata)
Creates a new read command on a single partition.
|
static SinglePartitionReadCommand |
create(TableMetadata metadata,
int nowInSec,
DecoratedKey key,
Clustering<?> name)
Creates a new single partition name command for the provided row.
|
static SinglePartitionReadCommand |
create(TableMetadata metadata,
int nowInSec,
DecoratedKey key,
ColumnFilter columnFilter,
ClusteringIndexFilter filter)
Creates a new read command on a single partition.
|
static SinglePartitionReadCommand |
create(TableMetadata metadata,
int nowInSec,
DecoratedKey key,
java.util.NavigableSet<Clustering<?>> names)
Creates a new single partition name command for the provided rows.
|
static SinglePartitionReadCommand |
create(TableMetadata metadata,
int nowInSec,
DecoratedKey key,
Slice slice)
Creates a new single partition slice command for the provided single slice.
|
static SinglePartitionReadCommand |
create(TableMetadata metadata,
int nowInSec,
DecoratedKey key,
Slices slices)
Creates a new single partition slice command for the provided slices.
|
PartitionIterator |
execute(ConsistencyLevel consistency,
ClientState state,
Dispatcher.RequestTime requestTime)
Executes the query at the provided consistency level.
|
PartitionIterator |
executeInternal(ReadExecutionController controller)
Execute the query for internal queries (that is, it basically executes the query locally).
|
SinglePartitionReadCommand |
forPaging(Clustering<?> lastReturned,
DataLimits limits)
Returns a new
SinglePartitionReadQuery suitable to paging from the last returned row. |
static SinglePartitionReadCommand |
fullPartitionRead(TableMetadata metadata,
int nowInSec,
java.nio.ByteBuffer key)
Creates a new read command that queries a single partition in its entirety.
|
static SinglePartitionReadCommand |
fullPartitionRead(TableMetadata metadata,
int nowInSec,
DecoratedKey key)
Creates a new read command that queries a single partition in its entirety.
|
long |
getTimeout(java.util.concurrent.TimeUnit unit)
The configured timeout for this command.
|
boolean |
isLimitedToOnePartition() |
boolean |
isRangeRequest() |
boolean |
isReversed()
Whether the underlying
ClusteringIndexFilter is reversed or not. |
DataLimits |
limits()
The limits for the query.
|
java.lang.String |
loggableTokens()
Return the queried token(s) for logging
|
TableMetadata |
metadata()
The metadata for the table this is a query on.
|
int |
nowInSec()
The time in seconds to use as "now" for this query.
|
DecoratedKey |
partitionKey()
Returns the key of the partition queried by this
ReadQuery |
UnfilteredRowIterator |
queryMemtableAndDisk(ColumnFamilyStore cfs,
ReadExecutionController executionController)
Queries both memtable and sstables to fetch the result of this query.
|
protected UnfilteredPartitionIterator |
queryStorage(ColumnFamilyStore cfs,
ReadExecutionController executionController) |
protected void |
recordLatency(TableMetrics metric,
long latencyNanos) |
RowFilter |
rowFilter()
Filters/Resrictions on CQL rows.
|
protected long |
selectionSerializedSize(int version) |
boolean |
selectsFullPartition()
Checks if this
ReadQuery selects full partitions, that is it has no filtering on clustering or regular columns. |
protected void |
serializeSelection(DataOutputPlus out,
int version) |
java.lang.String |
toCQLString()
Recreate the CQL string corresponding to this query.
|
java.lang.String |
toString() |
Verb |
verb() |
SinglePartitionReadCommand |
withUpdatedLimit(DataLimits newLimits)
Creates a new
ReadCommand instance with new limits. |
acceptsTransient, copyAsDigestQuery, copyAsDigestQuery, copyAsTransientQuery, copyAsTransientQuery, createEmptyResponse, createMessage, createResponse, digestVersion, executeLocally, executionController, executionController, getCommand, getIndex, indexMetadata, isDigestQuery, isSinglePartitionRead, isTrackingWarnings, maybeValidateIndex, name, setDigestVersion, trackWarnings, withoutPurgeableTombstones, withStateTracking
abort, complete, creationTimeNanos, isAborted, isCompleted, isCrossNode, isInProgress, isSlow, setMonitoringTime, slowTimeoutNanos, timeoutNanos
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createGroup, getPager, selectsClustering, selectsKey
columnFilter, empty, executeInternal, executeLocally, executionController, isEmpty, limits, maybeValidateIndex, metadata, nowInSec, rowFilter, trackWarnings
protected static final ReadCommand.SelectionDeserializer selectionDeserializer
protected final DecoratedKey partitionKey
protected final ClusteringIndexFilter clusteringIndexFilter
protected SinglePartitionReadCommand(boolean isDigest, int digestVersion, boolean acceptsTransient, TableMetadata metadata, int nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, IndexMetadata index, boolean trackWarnings)
public static SinglePartitionReadCommand create(TableMetadata metadata, int nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, IndexMetadata indexMetadata)
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.indexMetadata
- explicitly specified index to use for the querypublic static SinglePartitionReadCommand create(TableMetadata metadata, int nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter)
create
in interface SinglePartitionReadQuery
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.public static SinglePartitionReadCommand create(TableMetadata metadata, int nowInSec, DecoratedKey key, ColumnFilter columnFilter, ClusteringIndexFilter filter)
create
in interface SinglePartitionReadQuery
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.public static SinglePartitionReadCommand fullPartitionRead(TableMetadata metadata, int nowInSec, DecoratedKey key)
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.key
.public static SinglePartitionReadCommand fullPartitionRead(TableMetadata metadata, int nowInSec, java.nio.ByteBuffer key)
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.key
.public static SinglePartitionReadCommand create(TableMetadata metadata, int nowInSec, DecoratedKey key, Slice slice)
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.slice
in key
. The returned query will
query every columns for the table (without limit or row filtering) and be in forward order.public static SinglePartitionReadCommand create(TableMetadata metadata, int nowInSec, DecoratedKey key, Slices slices)
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.slices
in key
. The returned query will
query every columns for the table (without limit or row filtering) and be in forward order.public static SinglePartitionReadCommand create(TableMetadata metadata, int nowInSec, java.nio.ByteBuffer key, Slices slices)
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.slices
in key
. The returned query will
query every columns for the table (without limit or row filtering) and be in forward order.public static SinglePartitionReadCommand create(TableMetadata metadata, int nowInSec, DecoratedKey key, java.util.NavigableSet<Clustering<?>> names)
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.names
- the clustering for the rows to query.names
in key
. The returned query will
query every columns (without limit or row filtering) and be in forward order.public static SinglePartitionReadCommand create(TableMetadata metadata, int nowInSec, DecoratedKey key, Clustering<?> name)
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.name
in key
. The returned query will
query every columns (without limit or row filtering).public SinglePartitionReadCommand copy()
ReadCommand
copy
in class ReadCommand
protected SinglePartitionReadCommand copyAsDigestQuery()
copyAsDigestQuery
in class ReadCommand
protected SinglePartitionReadCommand copyAsTransientQuery()
copyAsTransientQuery
in class ReadCommand
public SinglePartitionReadCommand withUpdatedLimit(DataLimits newLimits)
ReadCommand
ReadCommand
instance with new limits.withUpdatedLimit
in interface SinglePartitionReadQuery
withUpdatedLimit
in class ReadCommand
newLimits
- the new limitsReadCommand
with the updated limitspublic DecoratedKey partitionKey()
SinglePartitionReadQuery
ReadQuery
partitionKey
in interface SinglePartitionReadQuery
public ClusteringIndexFilter clusteringIndexFilter()
clusteringIndexFilter
in interface SinglePartitionReadQuery
public ClusteringIndexFilter clusteringIndexFilter(DecoratedKey key)
ReadCommand
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.
clusteringIndexFilter
in class ReadCommand
key
- a partition key queried by this command.ClusteringIndexFilter
to use for the partition of key key
.public long getTimeout(java.util.concurrent.TimeUnit unit)
ReadCommand
getTimeout
in class ReadCommand
public boolean isReversed()
ReadCommand
ClusteringIndexFilter
is reversed or not.isReversed
in class ReadCommand
ClusteringIndexFilter
is reversed or not.public SinglePartitionReadCommand forPaging(Clustering<?> lastReturned, DataLimits limits)
SinglePartitionReadQuery
SinglePartitionReadQuery
suitable to paging from the last returned row.forPaging
in interface SinglePartitionReadQuery
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 be null
if this
is the first page.limits
- the limits to use for the page to query.public PartitionIterator execute(ConsistencyLevel consistency, ClientState state, Dispatcher.RequestTime requestTime) throws RequestExecutionException
ReadQuery
execute
in interface ReadQuery
consistency
- the consistency level to achieve for the query.state
- client stateRequestExecutionException
protected void recordLatency(TableMetrics metric, long latencyNanos)
recordLatency
in class ReadCommand
protected UnfilteredPartitionIterator queryStorage(ColumnFamilyStore cfs, ReadExecutionController executionController)
queryStorage
in class ReadCommand
public UnfilteredRowIterator queryMemtableAndDisk(ColumnFamilyStore cfs, ReadExecutionController executionController)
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 ReadExecutionController
on the queried table and we require it as
a parameter to enforce that fact, even though it's not explicitlly used by the method.
public boolean selectsFullPartition()
ReadQuery
ReadQuery
selects full partitions, that is it has no filtering on clustering or regular columns.selectsFullPartition
in interface ReadQuery
true
if this ReadQuery
selects full partitions, false
otherwise.public java.lang.String toString()
toString
in class java.lang.Object
public Verb verb()
verb
in class ReadCommand
protected void appendCQLWhereClause(java.lang.StringBuilder sb)
appendCQLWhereClause
in class ReadCommand
public java.lang.String loggableTokens()
ReadCommand
loggableTokens
in class ReadCommand
protected void serializeSelection(DataOutputPlus out, int version) throws java.io.IOException
serializeSelection
in class ReadCommand
java.io.IOException
protected long selectionSerializedSize(int version)
selectionSerializedSize
in class ReadCommand
public boolean isLimitedToOnePartition()
isLimitedToOnePartition
in class ReadCommand
public boolean isRangeRequest()
isRangeRequest
in class ReadCommand
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
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.
Copyright © 2009- The Apache Software Foundation