Class RowFilter

  • All Implemented Interfaces:
    java.lang.Iterable<RowFilter.Expression>

    public abstract class RowFilter
    extends java.lang.Object
    implements java.lang.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).

    • Method Detail

      • create

        public static RowFilter create​(int capacity)
      • addMapEquality

        public void addMapEquality​(ColumnMetadata def,
                                   java.nio.ByteBuffer key,
                                   Operator op,
                                   java.nio.ByteBuffer value)
      • addCustomIndexExpression

        public void addCustomIndexExpression​(TableMetadata metadata,
                                             IndexMetadata targetIndex,
                                             java.nio.ByteBuffer value)
      • hasExpressionOnClusteringOrRegularColumns

        public boolean hasExpressionOnClusteringOrRegularColumns()
        Checks if some of the expressions apply to clustering or regular columns.
        Returns:
        true if some of the expressions apply to clustering or regular columns, false otherwise.
      • filter

        public UnfilteredPartitionIterator filter​(UnfilteredPartitionIterator iter,
                                                  int nowInSec)
        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 filter
        nowInSec - the time of query in seconds.
        Returns:
        the filtered iterator.
      • filter

        public PartitionIterator filter​(PartitionIterator iter,
                                        TableMetadata metadata,
                                        int nowInSec)
        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 filter
        nowInSec - the time of query in seconds.
        Returns:
        the filtered iterator.
      • isSatisfiedBy

        public boolean isSatisfiedBy​(TableMetadata metadata,
                                     DecoratedKey partitionKey,
                                     Row row,
                                     int 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:
        true if row in partition partitionKey satisfies 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

        public boolean clusteringKeyRestrictionsAreSatisfiedBy​(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.
      • without

        public RowFilter without​(RowFilter.Expression expression)
        Returns this filter but without the provided expression. This method *assumes* that the filter contains the provided expression.
      • withoutExpressions

        public RowFilter withoutExpressions()
      • isEmpty

        public boolean isEmpty()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object