Search in sources :

Example 1 with ReferencedFields

use of com.apple.foundationdb.record.query.plan.temp.ReferencedFieldsAttribute.ReferencedFields in project fdb-record-layer by FoundationDB.

the class PushReferencedFieldsThroughDistinctRule method onMatch.

@Override
public void onMatch(@Nonnull PlannerRuleCall call) {
    final PlannerBindings bindings = call.getBindings();
    final ExpressionRef<? extends RelationalExpression> lowerRef = bindings.get(lowerRefMatcher);
    final Optional<ReferencedFields> referencedFieldsOptional = call.getInterestingProperty(ReferencedFieldsAttribute.REFERENCED_FIELDS);
    if (!referencedFieldsOptional.isPresent()) {
        return;
    }
    call.pushRequirement(lowerRef, ReferencedFieldsAttribute.REFERENCED_FIELDS, referencedFieldsOptional.get());
}
Also used : ReferencedFields(com.apple.foundationdb.record.query.plan.temp.ReferencedFieldsAttribute.ReferencedFields) PlannerBindings(com.apple.foundationdb.record.query.plan.temp.matchers.PlannerBindings)

Example 2 with ReferencedFields

use of com.apple.foundationdb.record.query.plan.temp.ReferencedFieldsAttribute.ReferencedFields in project fdb-record-layer by FoundationDB.

the class PushReferencedFieldsThroughSelectRule method onMatch.

@Override
public void onMatch(@Nonnull PlannerRuleCall call) {
    final PlannerBindings bindings = call.getBindings();
    final SelectExpression selectExpression = bindings.get(root);
    final List<? extends QueryPredicate> predicates = bindings.getAll(predicateMatcher);
    final Set<FieldValue> fieldValuesFromPredicates = RelationalExpressionWithPredicates.fieldValuesFromPredicates(predicates);
    final Set<FieldValue> fieldValuesFromResultValues = selectExpression.getFieldValuesFromResultValues();
    final ExpressionRef<? extends RelationalExpression> lowerRef = bindings.get(lowerRefMatcher);
    final ImmutableSet<FieldValue> allReferencedValues = ImmutableSet.<FieldValue>builder().addAll(call.getInterestingProperty(ReferencedFieldsAttribute.REFERENCED_FIELDS).map(ReferencedFields::getReferencedFieldValues).orElse(ImmutableSet.of())).addAll(fieldValuesFromPredicates).addAll(fieldValuesFromResultValues).build();
    call.pushRequirement(lowerRef, ReferencedFieldsAttribute.REFERENCED_FIELDS, new ReferencedFields(allReferencedValues));
}
Also used : ReferencedFields(com.apple.foundationdb.record.query.plan.temp.ReferencedFieldsAttribute.ReferencedFields) PlannerBindings(com.apple.foundationdb.record.query.plan.temp.matchers.PlannerBindings) SelectExpression(com.apple.foundationdb.record.query.plan.temp.expressions.SelectExpression) FieldValue(com.apple.foundationdb.record.query.predicates.FieldValue)

Example 3 with ReferencedFields

use of com.apple.foundationdb.record.query.plan.temp.ReferencedFieldsAttribute.ReferencedFields in project fdb-record-layer by FoundationDB.

the class PushReferencedFieldsThroughFilterRule method onMatch.

@Override
public void onMatch(@Nonnull PlannerRuleCall call) {
    final PlannerBindings bindings = call.getBindings();
    final List<? extends QueryPredicate> predicates = bindings.getAll(predicateMatcher);
    final Set<FieldValue> fieldValuesFromPredicates = RelationalExpressionWithPredicates.fieldValuesFromPredicates(predicates);
    final ExpressionRef<? extends RelationalExpression> lowerRef = bindings.get(lowerRefMatcher);
    final ImmutableSet<FieldValue> allReferencedValues = ImmutableSet.<FieldValue>builder().addAll(call.getInterestingProperty(ReferencedFieldsAttribute.REFERENCED_FIELDS).map(ReferencedFields::getReferencedFieldValues).orElse(ImmutableSet.of())).addAll(fieldValuesFromPredicates).build();
    call.pushRequirement(lowerRef, ReferencedFieldsAttribute.REFERENCED_FIELDS, new ReferencedFields(allReferencedValues));
}
Also used : ReferencedFields(com.apple.foundationdb.record.query.plan.temp.ReferencedFieldsAttribute.ReferencedFields) PlannerBindings(com.apple.foundationdb.record.query.plan.temp.matchers.PlannerBindings) FieldValue(com.apple.foundationdb.record.query.predicates.FieldValue)

Aggregations

ReferencedFields (com.apple.foundationdb.record.query.plan.temp.ReferencedFieldsAttribute.ReferencedFields)3 PlannerBindings (com.apple.foundationdb.record.query.plan.temp.matchers.PlannerBindings)3 FieldValue (com.apple.foundationdb.record.query.predicates.FieldValue)2 SelectExpression (com.apple.foundationdb.record.query.plan.temp.expressions.SelectExpression)1