use of com.apple.foundationdb.record.query.predicates.QueryComponentPredicate in project fdb-record-layer by FoundationDB.
the class PushFilterThroughFetchRule method pushLeafPredicate.
@Nullable
private QueryPredicate pushLeafPredicate(@Nonnull RecordQueryFetchFromPartialRecordPlan fetchPlan, @Nonnull CorrelationIdentifier newInnerAlias, @Nonnull final QueryPredicate leafPredicate) {
if (leafPredicate instanceof QueryComponentPredicate) {
// We cannot push these predicates. They always contain nesteds.
return null;
}
if (!(leafPredicate instanceof PredicateWithValue)) {
// appears to be pushable as is.
return leafPredicate;
}
final PredicateWithValue predicateWithValue = (PredicateWithValue) leafPredicate;
final Value value = predicateWithValue.getValue();
final Optional<Value> pushedValueOptional = fetchPlan.pushValue(value, newInnerAlias);
// We must return null to prevent pushing of this conjunct.
return pushedValueOptional.map(predicateWithValue::withValue).orElse(null);
}
use of com.apple.foundationdb.record.query.predicates.QueryComponentPredicate in project fdb-record-layer by FoundationDB.
the class ExpressionMatcherTest method anyRefMatcher.
@Test
public void anyRefMatcher() {
// create a matcher and expression to match
BindingMatcher<? extends ExpressionRef<? extends RelationalExpression>> matcher = ReferenceMatchers.anyRef();
Quantifier.ForEach quantifier = Quantifier.forEach(GroupExpressionRef.of(new RecordQueryScanPlan(ScanComparisons.EMPTY, false)));
ExpressionRef<RelationalExpression> root = GroupExpressionRef.of(new LogicalFilterExpression(ImmutableList.of(new QueryComponentPredicate(Query.field("test").equalsValue(5))), quantifier));
// try to match to expression
Optional<PlannerBindings> newBindings = matcher.bindMatches(PlannerBindings.empty(), root).findFirst();
// check the the bindings are what we expect, and that none of the existing ones were clobbered
assertTrue(newBindings.isPresent());
PlannerBindings allBindings = newBindings.get().mergedWith(getExistingBindings());
assertExistingBindingsSurvived(allBindings);
assertTrue(newBindings.get().containsKey(matcher));
assertTrue(allBindings.containsKey(matcher));
assertEquals(root, allBindings.get(matcher));
}
Aggregations