@Override public void addRowFilterTo(RowFilter filter, SecondaryIndexManager indexManager, QueryOptions options) { filter.add(columnDef, Operator.EQ, value.bindAndGet(options)); }
@Override public void addRowFilterTo(RowFilter filter, SecondaryIndexManager indexManager, QueryOptions options) { for (ByteBuffer value : bindAndGet(values, options)) filter.add(columnDef, Operator.CONTAINS, value); for (ByteBuffer key : bindAndGet(keys, options)) filter.add(columnDef, Operator.CONTAINS_KEY, key); List<ByteBuffer> eks = bindAndGet(entryKeys, options); List<ByteBuffer> evs = bindAndGet(entryValues, options); assert eks.size() == evs.size(); for (int i = 0; i < eks.size(); i++) filter.addMapEquality(columnDef, eks.get(i), Operator.EQ, evs.get(i)); }
public RowFilter getPostIndexQueryFilter(RowFilter filter) { return getTargetExpression(filter.getExpressions()).map(filter::without) .orElse(filter); }
protected void appendCQLWhereClause(StringBuilder sb) { if (dataRange.isUnrestricted() && rowFilter().isEmpty()) return; sb.append(" WHERE "); // We put the row filter first because the data range can end by "ORDER BY" if (!rowFilter().isEmpty()) { sb.append(rowFilter()); if (!dataRange.isUnrestricted()) sb.append(" AND "); } if (!dataRange.isUnrestricted()) sb.append(dataRange.toCQLString(metadata())); }
static RowFilter deserializeRowFilter(DataInputPlus in, CFMetaData metadata) throws IOException { int numRowFilters = in.readInt(); if (numRowFilters == 0) return RowFilter.NONE; RowFilter rowFilter = RowFilter.create(numRowFilters); for (int i = 0; i < numRowFilters; i++) { ByteBuffer columnName = ByteBufferUtil.readWithShortLength(in); ColumnDefinition column = metadata.getColumnDefinition(columnName); Operator op = Operator.readFrom(in); ByteBuffer indexValue = ByteBufferUtil.readWithShortLength(in); rowFilter.add(column, op, indexValue); } return rowFilter; }
public boolean selectsClustering(DecoratedKey key, Clustering clustering) { if (clustering == Clustering.STATIC_CLUSTERING) return !columnFilter().fetchedColumns().statics.isEmpty(); if (!clusteringIndexFilter().selects(clustering)) return false; return rowFilter().clusteringKeyRestrictionsAreSatisfiedBy(clustering); }
@Override public boolean selectsFullPartition() { return metadata().isStaticCompactTable() || (dataRange.selectsAllPartition() && !rowFilter().hasExpressionOnClusteringOrRegularColumns()); }
public void addToRowFilter(RowFilter filter, CFMetaData cfm, QueryOptions options) { filter.addCustomIndexExpression(cfm, cfm.getIndexes() .get(targetIndex.getIdx()) .orElseThrow(() -> IndexRestrictions.indexNotFound(targetIndex, cfm)), value.bindAndGet(options)); } }
public RowFilter getRowFilter(SecondaryIndexManager indexManager, QueryOptions options) { if (filterRestrictions.isEmpty()) return RowFilter.NONE; RowFilter filter = RowFilter.create(); for (Restrictions restrictions : filterRestrictions.getRestrictions()) restrictions.addRowFilterTo(filter, indexManager, options); for (CustomIndexExpression expression : filterRestrictions.getCustomIndexExpressions()) expression.addToRowFilter(filter, cfm, options); return filter; }
/** * Whether a given base row matches the view filter (and thus if is should have a corresponding entry). * <p> * Note that this differs from {@link #mayBeAffectedBy} in that the provide row <b>must</b> be the current * state of the base row, not just some updates to it. This method also has no false positive: a base * row either do or don't match the view filter. * * @param partitionKey the partition key that is updated. * @param baseRow the current state of a particular base row. * @param nowInSec the current time in seconds (to decide what is live and what isn't). * @return {@code true} if {@code baseRow} matches the view filters, {@code false} otherwise. */ public boolean matchesViewFilter(DecoratedKey partitionKey, Row baseRow, int nowInSec) { return getReadQuery().selectsClustering(partitionKey, baseRow.clustering()) && getSelectStatement().rowFilterForInternalCalls().isSatisfiedBy(baseCfs.metadata, partitionKey, baseRow, nowInSec); }
return limits().filter(updatedFilter.filter(resultIterator, nowInSec()), nowInSec(), selectsFullPartition());
protected void appendCQLWhereClause(StringBuilder sb) { if (dataRange.isUnrestricted() && rowFilter().isEmpty()) return; sb.append(" WHERE "); // We put the row filter first because the data range can end by "ORDER BY" if (!rowFilter().isEmpty()) { sb.append(rowFilter()); if (!dataRange.isUnrestricted()) sb.append(" AND "); } if (!dataRange.isUnrestricted()) sb.append(dataRange.toCQLString(metadata())); }
static RowFilter deserializeRowFilter(DataInputPlus in, CFMetaData metadata) throws IOException { int numRowFilters = in.readInt(); if (numRowFilters == 0) return RowFilter.NONE; RowFilter rowFilter = RowFilter.create(numRowFilters); for (int i = 0; i < numRowFilters; i++) { ByteBuffer columnName = ByteBufferUtil.readWithShortLength(in); ColumnDefinition column = metadata.getColumnDefinition(columnName); Operator op = Operator.readFrom(in); ByteBuffer indexValue = ByteBufferUtil.readWithShortLength(in); rowFilter.add(column, op, indexValue); } return rowFilter; }
public boolean selectsClustering(DecoratedKey key, Clustering clustering) { if (clustering == Clustering.STATIC_CLUSTERING) return !columnFilter().fetchedColumns().statics.isEmpty(); if (!clusteringIndexFilter().selects(clustering)) return false; return rowFilter().clusteringKeyRestrictionsAreSatisfiedBy(clustering); }
@Override public boolean selectsFullPartition() { return metadata().isStaticCompactTable() || (clusteringIndexFilter.selectsAllPartition() && !rowFilter().hasExpressionOnClusteringOrRegularColumns()); }
public void addToRowFilter(RowFilter filter, CFMetaData cfm, QueryOptions options) { filter.addCustomIndexExpression(cfm, cfm.getIndexes() .get(targetIndex.getIdx()) .orElseThrow(() -> IndexRestrictions.indexNotFound(targetIndex, cfm)), value.bindAndGet(options)); } }
public RowFilter getRowFilter(SecondaryIndexManager indexManager, QueryOptions options) { if (filterRestrictions.isEmpty()) return RowFilter.NONE; RowFilter filter = RowFilter.create(); for (Restrictions restrictions : filterRestrictions.getRestrictions()) restrictions.addRowFilterTo(filter, indexManager, options); for (CustomIndexExpression expression : filterRestrictions.getCustomIndexExpressions()) expression.addToRowFilter(filter, cfm, options); return filter; }
/** * Whether a given base row matches the view filter (and thus if is should have a corresponding entry). * <p> * Note that this differs from {@link #mayBeAffectedBy} in that the provide row <b>must</b> be the current * state of the base row, not just some updates to it. This method also has no false positive: a base * row either do or don't match the view filter. * * @param partitionKey the partition key that is updated. * @param baseRow the current state of a particular base row. * @param nowInSec the current time in seconds (to decide what is live and what isn't). * @return {@code true} if {@code baseRow} matches the view filters, {@code false} otherwise. */ public boolean matchesViewFilter(DecoratedKey partitionKey, Row baseRow, int nowInSec) { return getReadQuery().selectsClustering(partitionKey, baseRow.clustering()) && getSelectStatement().rowFilterForInternalCalls().isSatisfiedBy(baseCfs.metadata, partitionKey, baseRow, nowInSec); }
iterator = filter.filter(iterator, nowInSec());
public SimpleExpression add(ColumnDefinition def, Operator op, ByteBuffer value) { SimpleExpression expression = new SimpleExpression(def, op, value); add(expression); return expression; }