@Override public PartitionKeyRestrictions mergeWith(Restriction restriction) { if (restriction.isOnToken()) { if (isEmpty()) return (PartitionKeyRestrictions) restriction; return new TokenFilter(this, (TokenRestriction) restriction); } return new PartitionKeySingleRestrictionSet(this, (SingleRestriction) restriction); }
@Override public boolean needFiltering(CFMetaData cfm) { if (isEmpty()) return false; // slice or has unrestricted key component return hasUnrestrictedPartitionKeyComponents(cfm) || hasSlice() || hasContains(); }
/** * Converts the specified restriction into a <code>PartitionKeyRestrictions</code>. * * @param restriction the restriction to convert * @return a <code>PartitionKeyRestrictions</code> * @throws InvalidRequestException if a problem occurs while converting the restriction */ private PartitionKeyRestrictions toPartitionKeyRestrictions(Restriction restriction) throws InvalidRequestException { if (restriction instanceof PartitionKeyRestrictions) return (PartitionKeyRestrictions) restriction; return new PartitionKeySingleRestrictionSet(metadata.getKeyValidatorAsClusteringComparator()).mergeWith(restriction); }
@Override public List<ByteBuffer> values(QueryOptions options) { MultiCBuilder builder = MultiCBuilder.create(comparator, hasIN()); for (SingleRestriction r : restrictions) { r.appendTo(builder, options); if (builder.hasMissingElements()) break; } return toByteBuffers(builder.build()); }
@Override public boolean isInclusive(Bound b) { if (isEmpty()) return false; return restrictions.lastRestriction().isInclusive(b); }
@Override public boolean hasUnrestrictedPartitionKeyComponents(CFMetaData cfm) { return size() < cfm.partitionKeyColumns().size(); }
private StatementRestrictions(StatementType type, CFMetaData cfm, boolean allowFiltering) { this.type = type; this.cfm = cfm; this.partitionKeyRestrictions = new PartitionKeySingleRestrictionSet(cfm.getKeyValidatorAsClusteringComparator()); this.clusteringColumnsRestrictions = new ClusteringColumnRestrictions(cfm, allowFiltering); this.nonPrimaryKeyRestrictions = new RestrictionSet(); this.notNullColumns = new HashSet<>(); }
@Override public List<ByteBuffer> values(QueryOptions options) { MultiCBuilder builder = MultiCBuilder.create(comparator, hasIN()); for (SingleRestriction r : restrictions) { r.appendTo(builder, options); if (builder.hasMissingElements()) break; } return toByteBuffers(builder.build()); }
@Override public boolean hasBound(Bound b) { if (isEmpty()) return false; return restrictions.lastRestriction().hasBound(b); }
@Override public boolean hasUnrestrictedPartitionKeyComponents(CFMetaData cfm) { return size() < cfm.partitionKeyColumns().size(); }
private StatementRestrictions(StatementType type, CFMetaData cfm, boolean allowFiltering) { this.type = type; this.cfm = cfm; this.partitionKeyRestrictions = new PartitionKeySingleRestrictionSet(cfm.getKeyValidatorAsClusteringComparator()); this.clusteringColumnsRestrictions = new ClusteringColumnRestrictions(cfm, allowFiltering); this.nonPrimaryKeyRestrictions = new RestrictionSet(); this.notNullColumns = new HashSet<>(); }
@Override public boolean needFiltering(CFMetaData cfm) { if (isEmpty()) return false; // slice or has unrestricted key component return hasUnrestrictedPartitionKeyComponents(cfm) || hasSlice() || hasContains(); }
@Override public List<ByteBuffer> values(QueryOptions options) { MultiCBuilder builder = MultiCBuilder.create(comparator, hasIN()); for (SingleRestriction r : restrictions) { r.appendTo(builder, options); if (builder.hasMissingElements()) break; } return toByteBuffers(builder.build()); }
@Override public PartitionKeyRestrictions mergeWith(Restriction restriction) { if (restriction.isOnToken()) { if (isEmpty()) return (PartitionKeyRestrictions) restriction; return new TokenFilter(this, (TokenRestriction) restriction); } return new PartitionKeySingleRestrictionSet(this, (SingleRestriction) restriction); }
/** * Converts the specified restriction into a <code>PartitionKeyRestrictions</code>. * * @param restriction the restriction to convert * @return a <code>PartitionKeyRestrictions</code> * @throws InvalidRequestException if a problem occurs while converting the restriction */ private PartitionKeyRestrictions toPartitionKeyRestrictions(Restriction restriction) throws InvalidRequestException { if (restriction instanceof PartitionKeyRestrictions) return (PartitionKeyRestrictions) restriction; return new PartitionKeySingleRestrictionSet(metadata.getKeyValidatorAsClusteringComparator()).mergeWith(restriction); }
@Override public boolean hasBound(Bound b) { if (isEmpty()) return false; return restrictions.lastRestriction().hasBound(b); }
@Override public boolean hasUnrestrictedPartitionKeyComponents(CFMetaData cfm) { return size() < cfm.partitionKeyColumns().size(); }
private StatementRestrictions(StatementType type, CFMetaData cfm, boolean allowFiltering) { this.type = type; this.cfm = cfm; this.partitionKeyRestrictions = new PartitionKeySingleRestrictionSet(cfm.getKeyValidatorAsClusteringComparator()); this.clusteringColumnsRestrictions = new ClusteringColumnRestrictions(cfm, allowFiltering); this.nonPrimaryKeyRestrictions = new RestrictionSet(); this.notNullColumns = new HashSet<>(); }
@Override public boolean needFiltering(CFMetaData cfm) { if (isEmpty()) return false; // slice or has unrestricted key component return hasUnrestrictedPartitionKeyComponents(cfm) || hasSlice() || hasContains(); }
@Override public List<ByteBuffer> bounds(Bound bound, QueryOptions options) { MultiCBuilder builder = MultiCBuilder.create(comparator, hasIN()); for (SingleRestriction r : restrictions) { r.appendBoundTo(builder, bound, options); if (builder.hasMissingElements()) return Collections.emptyList(); } return toByteBuffers(builder.buildBound(bound.isStart(), true)); }