Package org.apache.cassandra.db.filter
Class RowFilter
java.lang.Object
org.apache.cassandra.db.filter.RowFilter
- All Implemented Interfaces:
Iterable<RowFilter.Expression>
A filter on which rows a given query should include or exclude.
This corresponds to the restrictions on rows that are not handled by the query
ClusteringIndexFilter. Some of the expressions of this filter may
be handled by a 2ndary index, and the rest is simply filtered out from the
result set (the later can only happen if the query was using ALLOW FILTERING).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA custom index expression for use with 2i implementations which support custom syntax and which are not necessarily linked to a single column in the base table.static classstatic classstatic classAn expression of the form 'column' 'op' 'value'.static classA user defined filtering expression. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<RowFilter.Expression>static final RowFilter.Serializer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRowFilter(List<RowFilter.Expression> expressions, boolean needsReconciliation) -
Method Summary
Modifier and TypeMethodDescriptionadd(ColumnMetadata def, Operator op, ByteBuffer value) voidaddCustomIndexExpression(TableMetadata metadata, IndexMetadata targetIndex, ByteBuffer value) voidaddMapEquality(ColumnMetadata def, ByteBuffer key, Operator op, ByteBuffer value) booleanclusteringKeyRestrictionsAreSatisfiedBy(Clustering<?> clustering) Returns true if all of the expressions within this filter that apply to the clustering key are satisfied by the given Clustering, false otherwise.static RowFiltercreate(boolean needsReconciliation) filter(PartitionIterator iter, TableMetadata metadata, long nowInSec) Filters the provided iterator so that only the row satisfying the expression of this filter are included in the resulting iterator.filter(UnfilteredPartitionIterator iter, long nowInSec) Filters the provided iterator so that only the row satisfying the expression of this filter are included in the resulting iterator.protected Transformation<BaseRowIterator<?>>filter(TableMetadata metadata, long nowInSec) Note that the application of this transformation does not yet takeisStrict()into account.booleanChecks if some of the expressions apply to clustering or regular columns.booleanbooleanbooleanisEmpty()booleanbooleanisSatisfiedBy(TableMetadata metadata, DecoratedKey partitionKey, Row row, long nowInSec) Whether the provided row in the provided partition satisfies this filter.booleanisStrict()If this filter belongs to a read that requires reconciliation at the coordinator, and it contains an intersection on two or more non-key (and therefore mutable) columns, we cannot strictly apply it to local, unrepaired rows.iterator()booleanstatic RowFilternone()booleanpartitionKeyRestrictionsAreSatisfiedBy(DecoratedKey key, AbstractType<?> keyValidator) Returns true if all of the expressions within this filter that apply to the partition key are satisfied by the given key, false otherwise.Returns a CQL representation of this row filter.toString()protected RowFilterwithNewExpressions(List<RowFilter.Expression> expressions) without(RowFilter.Expression expression) Returns this filter but without the provided expression.without(ColumnMetadata column, Operator op, ByteBuffer value) Returns a copy of this filter but without the provided expression.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
serializer
-
expressions
-
-
Constructor Details
-
RowFilter
-
-
Method Details
-
create
- Parameters:
needsReconciliation- whether or not this filter belongs to a read that requires coordinator reconciliation- Returns:
- a new
RowFilterwith an emptyRowFilter.Expressionlist
-
none
-
add
-
addMapEquality
-
addCustomIndexExpression
public void addCustomIndexExpression(TableMetadata metadata, IndexMetadata targetIndex, ByteBuffer value) -
getExpressions
-
needsReconciliation
public boolean needsReconciliation()- Returns:
- true if this filter belongs to a read that requires reconciliation at the coordinator
- See Also:
-
isStrict
public boolean isStrict()If this filter belongs to a read that requires reconciliation at the coordinator, and it contains an intersection on two or more non-key (and therefore mutable) columns, we cannot strictly apply it to local, unrepaired rows. When this occurs, we must downgrade the intersection of expressions to a union and leave the coordinator to filter strictly before sending results to the client.- Returns:
- true if strict filtering is safe
- See Also:
-
isMutableIntersection
public boolean isMutableIntersection()- Returns:
- true if this filter contains an intersection on either any static column or two regular mutable columns
-
hasExpressionOnClusteringOrRegularColumns
public boolean hasExpressionOnClusteringOrRegularColumns()Checks if some of the expressions apply to clustering or regular columns.- Returns:
trueif some of the expressions apply to clustering or regular columns,falseotherwise.
-
filter
Note that the application of this transformation does not yet takeisStrict()into account. This means that even when strict filtering is not safe, expressions will be applied as intersections rather than unions. The filter will always be evaluated strictly in conjunction with replica filtering protection at the coordinator, however, even after CASSANDRA-19007 is addressed.- See Also:
-
filter
Filters the provided iterator so that only the row satisfying the expression of this filter are included in the resulting iterator.- Parameters:
iter- the iterator to filternowInSec- the time of query in seconds.- Returns:
- the filtered iterator.
-
filter
Filters the provided iterator so that only the row satisfying the expression of this filter are included in the resulting iterator.- Parameters:
iter- the iterator to filternowInSec- the time of query in seconds.- Returns:
- the filtered iterator.
-
isSatisfiedBy
public boolean isSatisfiedBy(TableMetadata metadata, DecoratedKey partitionKey, Row row, long nowInSec) Whether the provided row in the provided partition satisfies this filter.- Parameters:
metadata- the table metadata.partitionKey- the partition key for partition to test.row- the row to test.nowInSec- the current time in seconds (to know what is live and what isn't).- Returns:
trueifrowin partitionpartitionKeysatisfies this row filter.
-
partitionKeyRestrictionsAreSatisfiedBy
public boolean partitionKeyRestrictionsAreSatisfiedBy(DecoratedKey key, AbstractType<?> keyValidator) Returns true if all of the expressions within this filter that apply to the partition key are satisfied by the given key, false otherwise. -
clusteringKeyRestrictionsAreSatisfiedBy
Returns true if all of the expressions within this filter that apply to the clustering key are satisfied by the given Clustering, false otherwise. -
without
Returns this filter but without the provided expression. This method *assumes* that the filter contains the provided expression. -
without
Returns a copy of this filter but without the provided expression. If this filter doesn't contain the specified expression this method will just return an identical copy of this filter. -
hasNonKeyExpression
public boolean hasNonKeyExpression() -
hasStaticExpression
public boolean hasStaticExpression() -
withoutExpressions
-
withNewExpressions
-
isEmpty
public boolean isEmpty() -
iterator
- Specified by:
iteratorin interfaceIterable<RowFilter.Expression>
-
toString
-
toCQLString
Returns a CQL representation of this row filter.- Returns:
- a CQL representation of this row filter
-