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 java.lang.Object
Restriction
using the token function.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TokenRestriction.EQRestriction
static class
TokenRestriction.SliceRestriction
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<ColumnMetadata>
columnDefs
The definition of the columns to which apply the token restriction.protected TableMetadata
metadata
-
Constructor Summary
Constructors Constructor Description TokenRestriction(TableMetadata metadata, java.util.List<ColumnMetadata> columnDefs)
Creates a newTokenRestriction
that apply to the specified columns.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addToRowFilter(RowFilter filter, IndexRegistry indexRegistry, QueryOptions options)
Adds to the specified row filter the expressions corresponding to thisRestriction
.java.util.List<java.nio.ByteBuffer>
bounds(Bound b, QueryOptions options)
protected abstract org.apache.cassandra.cql3.restrictions.PartitionKeyRestrictions
doMergeWith(TokenRestriction otherRestriction)
Merges this restriction with the specifiedTokenRestriction
.java.util.List<ColumnMetadata>
getColumnDefs()
Returns the column definitions in position order.protected java.lang.String
getColumnNamesAsString()
Returns the column names as a comma separatedString
.ColumnMetadata
getFirstColumn()
Returns the definition of the first column.ColumnMetadata
getLastColumn()
Returns the definition of the last column.java.util.Set<Restriction>
getRestrictions(ColumnMetadata columnDef)
Returns the restrictions applied to the specified column.boolean
hasBound(Bound b)
Checks if the specified bound is set or not.boolean
hasIN()
Checks if any of the underlying restriction is an IN.boolean
hasOnlyEqualityRestrictions()
Checks if all of the underlying restrictions are EQ or IN restrictions.boolean
hasSlice()
Checks if any of the underlying restrictions is a slice.boolean
hasSupportingIndex(IndexRegistry indexRegistry)
Check if the restriction is on indexed columns.boolean
hasUnrestrictedPartitionKeyComponents(TableMetadata table)
boolean
isEmpty()
Checks if thisRestrictions
is empty or not.boolean
isInclusive(Bound b)
Checks if the specified bound is inclusive or not.boolean
isOnToken()
org.apache.cassandra.cql3.restrictions.PartitionKeyRestrictions
mergeWith(Restriction otherRestriction)
boolean
needFiltering(TableMetadata table)
boolean
needsFiltering(Index.Group indexGroup)
Returns whether this restriction would need filtering if the specified index group were used.int
size()
Returns the number of columns that have a restriction.java.util.List<java.nio.ByteBuffer>
values(QueryOptions options, ClientState state)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.cql3.restrictions.Restriction
addFunctionsTo
-
Methods inherited from interface org.apache.cassandra.cql3.restrictions.Restrictions
getColumnDefinitions, hasContains
-
-
-
-
Field Detail
-
columnDefs
protected final java.util.List<ColumnMetadata> columnDefs
The definition of the columns to which apply the token restriction.
-
metadata
protected final TableMetadata metadata
-
-
Constructor Detail
-
TokenRestriction
public TokenRestriction(TableMetadata metadata, java.util.List<ColumnMetadata> columnDefs)
Creates a newTokenRestriction
that apply to the specified columns.- Parameters:
columnDefs
- the definition of the columns to which apply the token restriction
-
-
Method Detail
-
hasIN
public boolean hasIN()
Description copied from interface:Restrictions
Checks if any of the underlying restriction is an IN.- Specified by:
hasIN
in interfaceRestrictions
- 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 interfaceRestrictions
- Returns:
true
if all of the underlying restrictions are EQ or IN restrictions,false
otherwise
-
getRestrictions
public java.util.Set<Restriction> getRestrictions(ColumnMetadata columnDef)
Description copied from interface:Restrictions
Returns the restrictions applied to the specified column.- Specified by:
getRestrictions
in interfaceRestrictions
- Parameters:
columnDef
- the column definition- Returns:
- the restrictions applied to the specified column
-
isOnToken
public final boolean isOnToken()
- Specified by:
isOnToken
in interfaceRestriction
-
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 interfaceRestrictions
- Returns:
true
if any of the underlying restrictions is a slice,false
otherwise
-
hasUnrestrictedPartitionKeyComponents
public boolean hasUnrestrictedPartitionKeyComponents(TableMetadata table)
-
getColumnDefs
public java.util.List<ColumnMetadata> getColumnDefs()
Description copied from interface:Restriction
Returns the column definitions in position order.- Specified by:
getColumnDefs
in interfaceRestriction
- 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 interfaceRestriction
- 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 interfaceRestriction
- 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 interfaceRestriction
- 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 thisRestriction
.- Specified by:
addToRowFilter
in interfaceRestriction
- Parameters:
filter
- the row filter to add expressions toindexRegistry
- the index registryoptions
- the query options
-
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 interfaceRestriction
- Parameters:
indexGroup
- an index group- Returns:
true
if this would need filtering ifindexGroup
were used,false
otherwise
-
isEmpty
public final boolean isEmpty()
Description copied from interface:Restrictions
Checks if thisRestrictions
is empty or not.- Specified by:
isEmpty
in interfaceRestrictions
- Returns:
true
if thisRestrictions
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 interfaceRestrictions
- Returns:
- the number of columns that have a restriction.
-
getColumnNamesAsString
protected final java.lang.String getColumnNamesAsString()
Returns the column names as a comma separatedString
.- 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 specifiedTokenRestriction
.- Parameters:
otherRestriction
- theTokenRestriction
to merge with.- Throws:
InvalidRequestException
-
values
public abstract java.util.List<java.nio.ByteBuffer> values(QueryOptions options, ClientState state)
-
bounds
public abstract java.util.List<java.nio.ByteBuffer> bounds(Bound b, QueryOptions options)
-
hasBound
public abstract 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
public abstract 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
-
-