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; }
/** * Checks if the query need to use filtering. * @return <code>true</code> if the query need to use filtering, <code>false</code> otherwise. */ public boolean needFiltering() { int numberOfRestrictions = filterRestrictions.getCustomIndexExpressions().size(); for (Restrictions restrictions : filterRestrictions.getRestrictions()) numberOfRestrictions += restrictions.size(); return numberOfRestrictions > 1 || (numberOfRestrictions == 0 && !clusteringColumnsRestrictions.isEmpty()) || (numberOfRestrictions != 0 && nonPrimaryKeyRestrictions.hasMultipleContains()); }
private void processCustomIndexExpressions(List<CustomIndexExpression> expressions, VariableSpecifications boundNames, SecondaryIndexManager indexManager) { if (!MessagingService.instance().areAllNodesAtLeast30()) throw new InvalidRequestException("Please upgrade all nodes to at least 3.0 before using custom index expressions"); if (expressions.size() > 1) throw new InvalidRequestException(IndexRestrictions.MULTIPLE_EXPRESSIONS); CustomIndexExpression expression = expressions.get(0); CFName cfName = expression.targetIndex.getCfName(); if (cfName.hasKeyspace() && !expression.targetIndex.getKeyspace().equals(cfm.ksName)) throw IndexRestrictions.invalidIndex(expression.targetIndex, cfm); if (cfName.getColumnFamily() != null && !cfName.getColumnFamily().equals(cfm.cfName)) throw IndexRestrictions.invalidIndex(expression.targetIndex, cfm); if (!cfm.getIndexes().has(expression.targetIndex.getIdx())) throw IndexRestrictions.indexNotFound(expression.targetIndex, cfm); Index index = indexManager.getIndex(cfm.getIndexes().get(expression.targetIndex.getIdx()).get()); if (!index.getIndexMetadata().isCustom()) throw IndexRestrictions.nonCustomIndexInExpression(expression.targetIndex); AbstractType<?> expressionType = index.customExpressionValueType(); if (expressionType == null) throw IndexRestrictions.customExpressionNotSupported(expression.targetIndex); expression.prepareValue(cfm, expressionType, boundNames); filterRestrictions.add(expression); }
private final IndexRestrictions filterRestrictions = new IndexRestrictions(); hasQueriableIndex = !filterRestrictions.getCustomIndexExpressions().isEmpty() || hasQueriableClusteringColumnIndex || partitionKeyRestrictions.hasSupportingIndex(secondaryIndexManager) filterRestrictions.add(partitionKeyRestrictions); filterRestrictions.add(clusteringColumnsRestrictions); "Filtering is not supported on SuperColumn tables"); filterRestrictions.add(nonPrimaryKeyRestrictions);
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)); } }
/** * Returns the non-PK column that are restricted. If includeNotNullRestrictions is true, columns that are restricted * by an IS NOT NULL restriction will be included, otherwise they will not be included (unless another restriction * applies to them). */ public Set<ColumnDefinition> nonPKRestrictedColumns(boolean includeNotNullRestrictions) { Set<ColumnDefinition> columns = new HashSet<>(); for (Restrictions r : filterRestrictions.getRestrictions()) { for (ColumnDefinition def : r.getColumnDefs()) if (!def.isPrimaryKeyColumn()) columns.add(def); } if (includeNotNullRestrictions) { for (ColumnDefinition def : notNullColumns) { if (!def.isPrimaryKeyColumn()) columns.add(def); } } return columns; }
private void processCustomIndexExpressions(List<CustomIndexExpression> expressions, VariableSpecifications boundNames, SecondaryIndexManager indexManager) { if (!MessagingService.instance().areAllNodesAtLeast30()) throw new InvalidRequestException("Please upgrade all nodes to at least 3.0 before using custom index expressions"); if (expressions.size() > 1) throw new InvalidRequestException(IndexRestrictions.MULTIPLE_EXPRESSIONS); CustomIndexExpression expression = expressions.get(0); CFName cfName = expression.targetIndex.getCfName(); if (cfName.hasKeyspace() && !expression.targetIndex.getKeyspace().equals(cfm.ksName)) throw IndexRestrictions.invalidIndex(expression.targetIndex, cfm); if (cfName.getColumnFamily() != null && !cfName.getColumnFamily().equals(cfm.cfName)) throw IndexRestrictions.invalidIndex(expression.targetIndex, cfm); if (!cfm.getIndexes().has(expression.targetIndex.getIdx())) throw IndexRestrictions.indexNotFound(expression.targetIndex, cfm); Index index = indexManager.getIndex(cfm.getIndexes().get(expression.targetIndex.getIdx()).get()); if (!index.getIndexMetadata().isCustom()) throw IndexRestrictions.nonCustomIndexInExpression(expression.targetIndex); AbstractType<?> expressionType = index.customExpressionValueType(); if (expressionType == null) throw IndexRestrictions.customExpressionNotSupported(expression.targetIndex); expression.prepareValue(cfm, expressionType, boundNames); filterRestrictions.add(expression); }
private final IndexRestrictions filterRestrictions = new IndexRestrictions(); hasQueriableIndex = !filterRestrictions.getCustomIndexExpressions().isEmpty() || hasQueriableClusteringColumnIndex || partitionKeyRestrictions.hasSupportingIndex(secondaryIndexManager) filterRestrictions.add(partitionKeyRestrictions); filterRestrictions.add(clusteringColumnsRestrictions); "Filtering is not supported on SuperColumn tables"); filterRestrictions.add(nonPrimaryKeyRestrictions);
/** * Checks if the query need to use filtering. * @return <code>true</code> if the query need to use filtering, <code>false</code> otherwise. */ public boolean needFiltering() { int numberOfRestrictions = filterRestrictions.getCustomIndexExpressions().size(); for (Restrictions restrictions : filterRestrictions.getRestrictions()) numberOfRestrictions += restrictions.size(); return numberOfRestrictions > 1 || (numberOfRestrictions == 0 && !clusteringColumnsRestrictions.isEmpty()) || (numberOfRestrictions != 0 && nonPrimaryKeyRestrictions.hasMultipleContains()); }
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)); } }
/** * Returns the non-PK column that are restricted. If includeNotNullRestrictions is true, columns that are restricted * by an IS NOT NULL restriction will be included, otherwise they will not be included (unless another restriction * applies to them). */ public Set<ColumnDefinition> nonPKRestrictedColumns(boolean includeNotNullRestrictions) { Set<ColumnDefinition> columns = new HashSet<>(); for (Restrictions r : filterRestrictions.getRestrictions()) { for (ColumnDefinition def : r.getColumnDefs()) if (!def.isPrimaryKeyColumn()) columns.add(def); } if (includeNotNullRestrictions) { for (ColumnDefinition def : notNullColumns) { if (!def.isPrimaryKeyColumn()) columns.add(def); } } return columns; }
private void processCustomIndexExpressions(List<CustomIndexExpression> expressions, VariableSpecifications boundNames, SecondaryIndexManager indexManager) { if (!MessagingService.instance().areAllNodesAtLeast30()) throw new InvalidRequestException("Please upgrade all nodes to at least 3.0 before using custom index expressions"); if (expressions.size() > 1) throw new InvalidRequestException(IndexRestrictions.MULTIPLE_EXPRESSIONS); CustomIndexExpression expression = expressions.get(0); CFName cfName = expression.targetIndex.getCfName(); if (cfName.hasKeyspace() && !expression.targetIndex.getKeyspace().equals(cfm.ksName)) throw IndexRestrictions.invalidIndex(expression.targetIndex, cfm); if (cfName.getColumnFamily() != null && !cfName.getColumnFamily().equals(cfm.cfName)) throw IndexRestrictions.invalidIndex(expression.targetIndex, cfm); if (!cfm.getIndexes().has(expression.targetIndex.getIdx())) throw IndexRestrictions.indexNotFound(expression.targetIndex, cfm); Index index = indexManager.getIndex(cfm.getIndexes().get(expression.targetIndex.getIdx()).get()); if (!index.getIndexMetadata().isCustom()) throw IndexRestrictions.nonCustomIndexInExpression(expression.targetIndex); AbstractType<?> expressionType = index.customExpressionValueType(); if (expressionType == null) throw IndexRestrictions.customExpressionNotSupported(expression.targetIndex); expression.prepareValue(cfm, expressionType, boundNames); filterRestrictions.add(expression); }
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; }
private final IndexRestrictions filterRestrictions = new IndexRestrictions(); hasQueriableIndex = !filterRestrictions.getCustomIndexExpressions().isEmpty() || hasQueriableClusteringColumnIndex || partitionKeyRestrictions.hasSupportingIndex(secondaryIndexManager) filterRestrictions.add(partitionKeyRestrictions); filterRestrictions.add(clusteringColumnsRestrictions); "Filtering is not supported on SuperColumn tables"); filterRestrictions.add(nonPrimaryKeyRestrictions);
/** * Checks if the query need to use filtering. * @return <code>true</code> if the query need to use filtering, <code>false</code> otherwise. */ public boolean needFiltering() { int numberOfRestrictions = filterRestrictions.getCustomIndexExpressions().size(); for (Restrictions restrictions : filterRestrictions.getRestrictions()) numberOfRestrictions += restrictions.size(); return numberOfRestrictions > 1 || (numberOfRestrictions == 0 && !clusteringColumnsRestrictions.isEmpty()) || (numberOfRestrictions != 0 && nonPrimaryKeyRestrictions.hasMultipleContains()); }
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)); } }
/** * Returns the non-PK column that are restricted. If includeNotNullRestrictions is true, columns that are restricted * by an IS NOT NULL restriction will be included, otherwise they will not be included (unless another restriction * applies to them). */ public Set<ColumnDefinition> nonPKRestrictedColumns(boolean includeNotNullRestrictions) { Set<ColumnDefinition> columns = new HashSet<>(); for (Restrictions r : filterRestrictions.getRestrictions()) { for (ColumnDefinition def : r.getColumnDefs()) if (!def.isPrimaryKeyColumn()) columns.add(def); } if (includeNotNullRestrictions) { for (ColumnDefinition def : notNullColumns) { if (!def.isPrimaryKeyColumn()) columns.add(def); } } return columns; }
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; }