Class TokenRestriction

java.lang.Object
org.apache.cassandra.cql3.restrictions.TokenRestriction
All Implemented Interfaces:
Restriction, Restrictions
Direct Known Subclasses:
TokenRestriction.EQRestriction, TokenRestriction.SliceRestriction

public abstract class TokenRestriction extends Object
Restriction using the token function.
  • Field Details

    • columnDefs

      protected final List<ColumnMetadata> columnDefs
      The definition of the columns to which apply the token restriction.
    • metadata

      protected final TableMetadata metadata
  • Constructor Details

    • TokenRestriction

      public TokenRestriction(TableMetadata metadata, List<ColumnMetadata> columnDefs)
      Creates a new TokenRestriction that apply to the specified columns.
      Parameters:
      columnDefs - the definition of the columns to which apply the token restriction
  • Method Details

    • hasIN

      public boolean hasIN()
      Description copied from interface: Restrictions
      Checks if any of the underlying restriction is an IN.
      Specified by:
      hasIN in interface Restrictions
      Returns:
      true if any of the underlying restriction is an IN, false otherwise
    • hasOnlyEqualityRestrictions

      public boolean hasOnlyEqualityRestrictions()
      Description copied from interface: Restrictions
      Checks if all of the underlying restrictions are EQ or IN restrictions.
      Specified by:
      hasOnlyEqualityRestrictions in interface Restrictions
      Returns:
      true if all of the underlying restrictions are EQ or IN restrictions, false otherwise
    • getRestrictions

      public Set<Restriction> getRestrictions(ColumnMetadata columnDef)
      Description copied from interface: Restrictions
      Returns the restrictions applied to the specified column.
      Specified by:
      getRestrictions in interface Restrictions
      Parameters:
      columnDef - the column definition
      Returns:
      the restrictions applied to the specified column
    • isOnToken

      public final boolean isOnToken()
      Specified by:
      isOnToken in interface Restriction
    • needFiltering

      public boolean needFiltering(TableMetadata table)
    • hasSlice

      public boolean hasSlice()
      Description copied from interface: Restrictions
      Checks if any of the underlying restrictions is a slice.
      Specified by:
      hasSlice in interface Restrictions
      Returns:
      true if any of the underlying restrictions is a slice, false otherwise
    • hasUnrestrictedPartitionKeyComponents

      public boolean hasUnrestrictedPartitionKeyComponents(TableMetadata table)
    • getColumnDefs

      public List<ColumnMetadata> getColumnDefs()
      Description copied from interface: Restriction
      Returns the column definitions in position order.
      Specified by:
      getColumnDefs in interface Restriction
      Returns:
      the column definitions in position order.
    • getFirstColumn

      public ColumnMetadata getFirstColumn()
      Description copied from interface: Restriction
      Returns the definition of the first column.
      Specified by:
      getFirstColumn in interface Restriction
      Returns:
      the definition of the first column.
    • getLastColumn

      public ColumnMetadata getLastColumn()
      Description copied from interface: Restriction
      Returns the definition of the last column.
      Specified by:
      getLastColumn in interface Restriction
      Returns:
      the definition of the last column.
    • hasSupportingIndex

      public boolean hasSupportingIndex(IndexRegistry indexRegistry)
      Description copied from interface: Restriction
      Check if the restriction is on indexed columns.
      Specified by:
      hasSupportingIndex in interface Restriction
      Parameters:
      indexRegistry - the index registry
      Returns:
      true if the restriction is on indexed columns, false
    • addToRowFilter

      public void addToRowFilter(RowFilter filter, IndexRegistry indexRegistry, QueryOptions options)
      Description copied from interface: Restriction
      Adds to the specified row filter the expressions corresponding to this Restriction.
      Specified by:
      addToRowFilter in interface Restriction
      Parameters:
      filter - the row filter to add expressions to
      indexRegistry - the index registry
      options - the query options
    • findSupportingIndex

      public Index findSupportingIndex(IndexRegistry indexRegistry)
      Description copied from interface: Restriction
      Find first supporting index for current restriction
      Specified by:
      findSupportingIndex in interface Restriction
      Parameters:
      indexRegistry - the index registry
      Returns:
      index if the restriction is on indexed columns, null
    • findSupportingIndexFromQueryPlan

      public Index findSupportingIndexFromQueryPlan(Index.QueryPlan indexQueryPlan)
      Description copied from interface: Restriction
      Find the first supporting index for the current restriction from an Index.QueryPlan.
      Specified by:
      findSupportingIndexFromQueryPlan in interface Restriction
      Parameters:
      indexQueryPlan - the index query plan
      Returns:
      index if the restriction is on indexed columns, null
    • needsFiltering

      public boolean needsFiltering(Index.Group indexGroup)
      Description copied from interface: Restriction
      Returns whether this restriction would need filtering if the specified index group were used.
      Specified by:
      needsFiltering in interface Restriction
      Parameters:
      indexGroup - an index group
      Returns:
      true if this would need filtering if indexGroup were used, false otherwise
    • isEmpty

      public final boolean isEmpty()
      Description copied from interface: Restrictions
      Checks if this Restrictions is empty or not.
      Specified by:
      isEmpty in interface Restrictions
      Returns:
      true if this Restrictions is empty, false otherwise.
    • size

      public final int size()
      Description copied from interface: Restrictions
      Returns the number of columns that have a restriction.
      Specified by:
      size in interface Restrictions
      Returns:
      the number of columns that have a restriction.
    • getColumnNamesAsString

      protected final String getColumnNamesAsString()
      Returns the column names as a comma separated String.
      Returns:
      the column names as a comma separated String.
    • mergeWith

      public final org.apache.cassandra.cql3.restrictions.PartitionKeyRestrictions mergeWith(Restriction otherRestriction) throws InvalidRequestException
      Throws:
      InvalidRequestException
    • doMergeWith

      protected abstract org.apache.cassandra.cql3.restrictions.PartitionKeyRestrictions doMergeWith(TokenRestriction otherRestriction) throws InvalidRequestException
      Merges this restriction with the specified TokenRestriction.
      Parameters:
      otherRestriction - the TokenRestriction to merge with.
      Throws:
      InvalidRequestException
    • values

      List<ByteBuffer> values(QueryOptions options, ClientState state)
    • bounds

      List<ByteBuffer> bounds(Bound b, QueryOptions options)
    • hasBound

      boolean hasBound(Bound b)
      Checks if the specified bound is set or not.
      Parameters:
      b - the bound type
      Returns:
      true if the specified bound is set, false otherwise
    • isInclusive

      boolean isInclusive(Bound b)
      Checks if the specified bound is inclusive or not.
      Parameters:
      b - the bound type
      Returns:
      true if the specified bound is inclusive, false otherwise