private ClusteringColumnRestrictions(ClusteringComparator comparator, RestrictionSet restrictionSet, boolean allowFiltering) { super(restrictionSet); this.comparator = comparator; this.allowFiltering = allowFiltering; }
public void addFunctionsTo(List<Function> functions) { restrictions.addFunctionsTo(functions); }
private PartitionKeySingleRestrictionSet(PartitionKeySingleRestrictionSet restrictionSet, SingleRestriction restriction) { super(restrictionSet.restrictions.addRestriction(restriction)); this.comparator = restrictionSet.comparator; }
hasRegularColumnsRestrictions = nonPrimaryKeyRestrictions.hasRestrictionFor(Kind.REGULAR); || hasQueriableClusteringColumnIndex || partitionKeyRestrictions.hasSupportingIndex(secondaryIndexManager) || nonPrimaryKeyRestrictions.hasSupportingIndex(secondaryIndexManager); if (!nonPrimaryKeyRestrictions.isEmpty()) ColumnDefinition.toIdentifiers(nonPrimaryKeyRestrictions.getColumnDefs());
public ClusteringColumnRestrictions mergeWith(Restriction restriction) throws InvalidRequestException { SingleRestriction newRestriction = (SingleRestriction) restriction; RestrictionSet newRestrictionSet = restrictions.addRestriction(newRestriction); if (!isEmpty() && !allowFiltering) { SingleRestriction lastRestriction = restrictions.lastRestriction(); ColumnDefinition lastRestrictionStart = lastRestriction.getFirstColumn(); ColumnDefinition newRestrictionStart = restriction.getFirstColumn(); checkFalse(lastRestriction.isSlice() && newRestrictionStart.position() > lastRestrictionStart.position(), "Clustering column \"%s\" cannot be restricted (preceding column \"%s\" is restricted by a non-EQ relation)", newRestrictionStart.name, lastRestrictionStart.name); if (newRestrictionStart.position() < lastRestrictionStart.position() && newRestriction.isSlice()) throw invalidRequest("PRIMARY KEY column \"%s\" cannot be restricted (preceding column \"%s\" is restricted by a non-EQ relation)", restrictions.nextColumn(newRestrictionStart).name, newRestrictionStart.name); } return new ClusteringColumnRestrictions(this.comparator, newRestrictionSet, allowFiltering); }
/** * Adds the specified restriction to this set of restrictions. * * @param restriction the restriction to add * @return the new set of restrictions */ public RestrictionSet addRestriction(SingleRestriction restriction) { // RestrictionSet is immutable so we need to clone the restrictions map. TreeMap<ColumnDefinition, SingleRestriction> newRestrictions = new TreeMap<>(this.restrictions); return new RestrictionSet(mergeRestrictions(newRestrictions, restriction), hasMultiColumnRestrictions || restriction.isMultiColumn()); }
private TreeMap<ColumnDefinition, SingleRestriction> mergeRestrictions(TreeMap<ColumnDefinition, SingleRestriction> restrictions, SingleRestriction restriction) { Collection<ColumnDefinition> columnDefs = restriction.getColumnDefs(); Set<SingleRestriction> existingRestrictions = getRestrictions(columnDefs); if (existingRestrictions.isEmpty()) { for (ColumnDefinition columnDef : columnDefs) restrictions.put(columnDef, restriction); } else { for (SingleRestriction existing : existingRestrictions) { SingleRestriction newRestriction = mergeRestrictions(existing, restriction); for (ColumnDefinition columnDef : columnDefs) restrictions.put(columnDef, newRestriction); } } return restrictions; }
public ColumnDefinition getFirstColumn() { return restrictions.getFirstColumn(); }
public List<ColumnDefinition> getColumnDefs() { return restrictions.getColumnDefs(); }
public void addRowFilterTo(RowFilter filter, SecondaryIndexManager indexManager, QueryOptions options) { restrictions.addRowFilterTo(filter, indexManager, options); }
public Set<Restriction> getRestrictions(ColumnDefinition columnDef) { return restrictions.getRestrictions(columnDef); } }
public ColumnDefinition getLastColumn() { return restrictions.getLastColumn(); }
public boolean hasContains() { return restrictions.hasContains(); }
public boolean hasIN() { return restrictions.hasIN(); }
hasRegularColumnsRestrictions = nonPrimaryKeyRestrictions.hasRestrictionFor(Kind.REGULAR); || hasQueriableClusteringColumnIndex || partitionKeyRestrictions.hasSupportingIndex(secondaryIndexManager) || nonPrimaryKeyRestrictions.hasSupportingIndex(secondaryIndexManager); if (!nonPrimaryKeyRestrictions.isEmpty()) ColumnDefinition.toIdentifiers(nonPrimaryKeyRestrictions.getColumnDefs());
public ClusteringColumnRestrictions mergeWith(Restriction restriction) throws InvalidRequestException { SingleRestriction newRestriction = (SingleRestriction) restriction; RestrictionSet newRestrictionSet = restrictions.addRestriction(newRestriction); if (!isEmpty() && !allowFiltering) { SingleRestriction lastRestriction = restrictions.lastRestriction(); ColumnDefinition lastRestrictionStart = lastRestriction.getFirstColumn(); ColumnDefinition newRestrictionStart = restriction.getFirstColumn(); checkFalse(lastRestriction.isSlice() && newRestrictionStart.position() > lastRestrictionStart.position(), "Clustering column \"%s\" cannot be restricted (preceding column \"%s\" is restricted by a non-EQ relation)", newRestrictionStart.name, lastRestrictionStart.name); if (newRestrictionStart.position() < lastRestrictionStart.position() && newRestriction.isSlice()) throw invalidRequest("PRIMARY KEY column \"%s\" cannot be restricted (preceding column \"%s\" is restricted by a non-EQ relation)", restrictions.nextColumn(newRestrictionStart).name, newRestrictionStart.name); } return new ClusteringColumnRestrictions(this.comparator, newRestrictionSet, allowFiltering); }
/** * Adds the specified restriction to this set of restrictions. * * @param restriction the restriction to add * @return the new set of restrictions */ public RestrictionSet addRestriction(SingleRestriction restriction) { // RestrictionSet is immutable so we need to clone the restrictions map. TreeMap<ColumnDefinition, SingleRestriction> newRestrictions = new TreeMap<>(this.restrictions); return new RestrictionSet(mergeRestrictions(newRestrictions, restriction), hasMultiColumnRestrictions || restriction.isMultiColumn()); }
private TreeMap<ColumnDefinition, SingleRestriction> mergeRestrictions(TreeMap<ColumnDefinition, SingleRestriction> restrictions, SingleRestriction restriction) { Collection<ColumnDefinition> columnDefs = restriction.getColumnDefs(); Set<SingleRestriction> existingRestrictions = getRestrictions(columnDefs); if (existingRestrictions.isEmpty()) { for (ColumnDefinition columnDef : columnDefs) restrictions.put(columnDef, restriction); } else { for (SingleRestriction existing : existingRestrictions) { SingleRestriction newRestriction = mergeRestrictions(existing, restriction); for (ColumnDefinition columnDef : columnDefs) restrictions.put(columnDef, newRestriction); } } return restrictions; }
public ColumnDefinition getFirstColumn() { return restrictions.getFirstColumn(); }
public List<ColumnDefinition> getColumnDefs() { return restrictions.getColumnDefs(); }