Class 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.
  • Field Details

  • Constructor Details

  • Method Details

    • create

      public static PartitionRangeReadCommand create(TableMetadata metadata, long nowInSec, ColumnFilter columnFilter, RowFilter rowFilter, DataLimits limits, DataRange dataRange)
    • allDataRead

      public static PartitionRangeReadCommand allDataRead(TableMetadata metadata, long 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.
    • clusteringIndexFilter

      public ClusteringIndexFilter clusteringIndexFilter(DecoratedKey key)
      Description copied from class: ReadCommand
      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.

      Specified by:
      clusteringIndexFilter in class ReadCommand
      Parameters:
      key - a partition key queried by this command.
      Returns:
      the ClusteringIndexFilter to use for the partition of key key.
    • 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 - whether range is a direct continuation of whatever previous range we have queried. This matters for the DataLimits that 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 which isRangeContinuation is 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 of StorageProxy.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 the DataLimits will have not state and the value of this parameter doesn't matter.
    • copy

      Description copied from class: ReadCommand
      Returns a copy of this command.
      Specified by:
      copy in class ReadCommand
      Returns:
      a copy of this command.
    • copyAsDigestQuery

      protected PartitionRangeReadCommand copyAsDigestQuery()
      Specified by:
      copyAsDigestQuery in class ReadCommand
    • copyAsTransientQuery

      protected PartitionRangeReadCommand copyAsTransientQuery()
      Specified by:
      copyAsTransientQuery in class ReadCommand
    • withUpdatedLimit

      public PartitionRangeReadCommand withUpdatedLimit(DataLimits newLimits)
      Description copied from class: ReadCommand
      Creates a new ReadCommand instance with new limits.
      Specified by:
      withUpdatedLimit in interface PartitionRangeReadQuery
      Specified by:
      withUpdatedLimit in class ReadCommand
      Parameters:
      newLimits - the new limits
      Returns:
      a new ReadCommand with the updated limits
    • withUpdatedLimitsAndDataRange

      public PartitionRangeReadCommand withUpdatedLimitsAndDataRange(DataLimits newLimits, DataRange newDataRange)
      Description copied from interface: PartitionRangeReadQuery
      Creates a new PartitionRangeReadQuery with the updated limits and data range.
      Specified by:
      withUpdatedLimitsAndDataRange in interface PartitionRangeReadQuery
      Parameters:
      newLimits - the new limits
      Returns:
      the new PartitionRangeReadQuery
    • getTimeout

      public long getTimeout(TimeUnit unit)
      Description copied from class: ReadCommand
      The configured timeout for this command.
      Specified by:
      getTimeout in class ReadCommand
      Returns:
      the configured timeout for this command.
    • isReversed

      public boolean isReversed()
      Description copied from class: ReadCommand
      Whether the underlying ClusteringIndexFilter is reversed or not.
      Specified by:
      isReversed in class ReadCommand
      Returns:
      whether the underlying ClusteringIndexFilter is reversed or not.
    • execute

      public PartitionIterator execute(ConsistencyLevel consistency, ClientState state, Dispatcher.RequestTime requestTime) throws RequestExecutionException
      Description copied from interface: ReadQuery
      Executes the query at the provided consistency level.
      Specified by:
      execute in interface ReadQuery
      Parameters:
      consistency - the consistency level to achieve for the query.
      state - client state
      requestTime - request enqueue / and start times
      Returns:
      the result of the query.
      Throws:
      RequestExecutionException
    • recordLatency

      protected void recordLatency(TableMetrics metric, long latencyNanos)
      Specified by:
      recordLatency in class ReadCommand
    • queryStorage

      Specified by:
      queryStorage in class ReadCommand
    • intersects

      protected boolean intersects(SSTableReader sstable)
      Specified by:
      intersects in class ReadCommand
    • verb

      public Verb verb()
      Specified by:
      verb in class ReadCommand
    • appendCQLWhereClause

      protected void appendCQLWhereClause(StringBuilder sb)
      Specified by:
      appendCQLWhereClause in class ReadCommand
    • loggableTokens

      public String loggableTokens()
      Description copied from class: ReadCommand
      Return the queried token(s) for logging
      Specified by:
      loggableTokens in class ReadCommand
    • 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 String toString()
      Overrides:
      toString in class Object
    • serializeSelection

      protected void serializeSelection(DataOutputPlus out, int version) throws IOException
      Specified by:
      serializeSelection in class ReadCommand
      Throws:
      IOException
    • selectionSerializedSize

      protected long selectionSerializedSize(int version)
      Specified by:
      selectionSerializedSize in class ReadCommand
    • isLimitedToOnePartition

      public boolean isLimitedToOnePartition()
      Specified by:
      isLimitedToOnePartition in class ReadCommand
    • isRangeRequest

      public boolean isRangeRequest()
      Specified by:
      isRangeRequest in class ReadCommand
    • metadata

      public TableMetadata metadata()
      Description copied from interface: ReadQuery
      The metadata for the table this is a query on.
      Specified by:
      metadata in interface ReadQuery
      Returns:
      the metadata for the table this is a query on.
    • executeInternal

      public PartitionIterator executeInternal(ReadExecutionController controller)
      Description copied from interface: ReadQuery
      Execute the query for internal queries (that is, it basically executes the query locally).
      Specified by:
      executeInternal in interface ReadQuery
      Parameters:
      controller - the ReadExecutionController protecting the read.
      Returns:
      the result of the query.
    • limits

      public DataLimits limits()
      Description copied from interface: ReadQuery
      The limits for the query.
      Specified by:
      limits in interface ReadQuery
      Returns:
      The limits for the query.
    • nowInSec

      public long nowInSec()
      Description copied from interface: ReadQuery
      The 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).

      Specified by:
      nowInSec in interface ReadQuery
      Returns:
      the time (in seconds) to use as "now".
    • rowFilter

      public RowFilter rowFilter()
      Description copied from interface: ReadQuery
      Filters/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.

      Specified by:
      rowFilter in interface ReadQuery
      Returns:
      the filter holding the expression that rows must satisfy.
    • columnFilter

      public ColumnFilter columnFilter()
      Description copied from interface: ReadQuery
      A filter on which (non-PK) columns must be returned by the query.
      Specified by:
      columnFilter in interface ReadQuery
      Returns:
      which columns must be fetched by this query.
    • toCQLString

      public 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.