use of com.apple.foundationdb.record.query.predicates.ExistsPredicate in project fdb-record-layer by FoundationDB.
the class OneOfThemWithComparison method expand.
@Override
public GraphExpansion expand(@Nonnull final CorrelationIdentifier baseAlias, @Nonnull final List<String> fieldNamePrefix) {
List<String> fieldNames = ImmutableList.<String>builder().addAll(fieldNamePrefix).add(getFieldName()).build();
final Quantifier childBase = Quantifier.forEach(GroupExpressionRef.of(ExplodeExpression.explodeField(baseAlias, 0, fieldNames)));
final SelectExpression selectExpression = GraphExpansion.ofPredicate(QuantifiedObjectValue.of(childBase.getAlias()).withComparison(comparison)).buildSelectWithBase(childBase);
final Quantifier.Existential childQuantifier = Quantifier.existential(GroupExpressionRef.of(selectExpression));
// create a query component that creates a path to this prefix and then applies this to it
// this is needed for reapplication of the component if the sub query cannot be matched or only matched with
// compensation
QueryComponent withPrefix = this;
for (int i = fieldNamePrefix.size() - 1; i >= 0; i--) {
final String fieldName = fieldNames.get(i);
withPrefix = Query.field(fieldName).matches(withPrefix);
}
return GraphExpansion.ofPredicateAndQuantifier(new ExistsPredicate(childQuantifier.getAlias(), withPrefix), childQuantifier);
}
use of com.apple.foundationdb.record.query.predicates.ExistsPredicate in project fdb-record-layer by FoundationDB.
the class OneOfThemWithComponent method expand.
@Override
public GraphExpansion expand(@Nonnull final CorrelationIdentifier baseAlias, @Nonnull final List<String> fieldNamePrefix) {
List<String> fieldNames = ImmutableList.<String>builder().addAll(fieldNamePrefix).add(getFieldName()).build();
final Quantifier.ForEach childBase = Quantifier.forEach(GroupExpressionRef.of(ExplodeExpression.explodeField(baseAlias, 0, fieldNames)));
final GraphExpansion graphExpansion = getChild().expand(childBase.getAlias(), Collections.emptyList());
final SelectExpression selectExpression = graphExpansion.buildSelectWithBase(childBase);
Quantifier.Existential childQuantifier = Quantifier.existential(GroupExpressionRef.of(selectExpression));
// create a query component that creates a path to this prefix and then applies this to it
// this is needed for reapplication of the component if the sub query cannot be matched or only matched with
// compensation
QueryComponent withPrefix = this;
for (int i = fieldNamePrefix.size() - 1; i >= 0; i--) {
final String fieldName = fieldNames.get(i);
withPrefix = Query.field(fieldName).matches(withPrefix);
}
return GraphExpansion.ofPredicateAndQuantifier(new ExistsPredicate(childQuantifier.getAlias(), withPrefix), childQuantifier);
}
Aggregations