Class DataLimits

java.lang.Object
org.apache.cassandra.db.filter.DataLimits

public abstract class DataLimits extends Object
Object in charge of tracking if we have fetch enough data for a given query. This is more complicated than a single count because we support PER PARTITION limits, but also due to GROUP BY and paging.
  • Field Details

  • Constructor Details

    • DataLimits

      public DataLimits()
  • Method Details

    • cqlLimits

      public static DataLimits cqlLimits(int cqlRowLimit)
    • cqlLimits

      public static DataLimits cqlLimits(int cqlRowLimit, int perPartitionLimit)
    • groupByLimits

      public static DataLimits groupByLimits(int groupLimit, int groupPerPartitionLimit, int rowLimit, AggregationSpecification groupBySpec)
    • distinctLimits

      public static DataLimits distinctLimits(int cqlRowLimit)
    • kind

      public abstract DataLimits.Kind kind()
    • isUnlimited

      public abstract boolean isUnlimited()
    • isDistinct

      public abstract boolean isDistinct()
    • isGroupByLimit

      public boolean isGroupByLimit()
    • isExhausted

      public boolean isExhausted(DataLimits.Counter counter)
    • forPaging

      public abstract DataLimits forPaging(int pageSize)
    • forPaging

      public abstract DataLimits forPaging(int pageSize, ByteBuffer lastReturnedKey, int lastReturnedKeyRemaining)
    • forShortReadRetry

      public abstract DataLimits forShortReadRetry(int toFetch)
    • forGroupByInternalPaging

      public DataLimits forGroupByInternalPaging(GroupingState state)
      Creates a DataLimits instance to be used for paginating internally GROUP BY queries.
      Parameters:
      state - the GroupMaker state
      Returns:
      a DataLimits instance to be used for paginating internally GROUP BY queries
    • hasEnoughLiveData

      public abstract boolean hasEnoughLiveData(CachedPartition cached, long nowInSec, boolean countPartitionsWithOnlyStaticData, boolean enforceStrictLiveness)
    • newCounter

      public abstract DataLimits.Counter newCounter(long nowInSec, boolean assumeLiveData, boolean countPartitionsWithOnlyStaticData, boolean enforceStrictLiveness)
      Returns a new Counter for this limits.
      Parameters:
      nowInSec - the current time in second (to decide what is expired or not).
      assumeLiveData - if true, the counter will assume that every row passed is live and won't thus check for liveness, otherwise it will. This should be true when used on a RowIterator (since it only returns live rows), false otherwise.
      countPartitionsWithOnlyStaticData - if true the partitions with only static data should be counted as 1 valid row.
      enforceStrictLiveness - whether the row should be purged if there is no PK liveness info, normally retrieved from TableMetadata.enforceStrictLiveness()
      Returns:
      a new Counter for this limits.
    • count

      public abstract int count()
      The max number of results this limits enforces.

      Note that the actual definition of "results" depends a bit: for "normal" queries it's a number of rows, but for GROUP BY queries it's a number of groups.

      Returns:
      the maximum number of results this limits enforces.
    • perPartitionCount

      public abstract int perPartitionCount()
    • withoutState

      public abstract DataLimits withoutState()
      Returns equivalent limits but where any internal state kept to track where we are of paging and/or grouping is discarded.
    • filter

      public UnfilteredPartitionIterator filter(UnfilteredPartitionIterator iter, long nowInSec, boolean countPartitionsWithOnlyStaticData)
    • filter

      public UnfilteredRowIterator filter(UnfilteredRowIterator iter, long nowInSec, boolean countPartitionsWithOnlyStaticData)
    • filter

      public PartitionIterator filter(PartitionIterator iter, long nowInSec, boolean countPartitionsWithOnlyStaticData, boolean enforceStrictLiveness)
    • estimateTotalResults

      public abstract float estimateTotalResults(ColumnFamilyStore cfs)
      Estimate the number of results that a full scan of the provided cfs would yield.