use of com.apple.foundationdb.record.query.plan.temp.expressions.FullUnorderedScanExpression in project fdb-record-layer by FoundationDB.
the class RelationalExpression method fromRecordQuery.
@Nonnull
static RelationalExpression fromRecordQuery(@Nonnull PlanContext context, @Nonnull RecordQuery query) {
query.validate(context.getMetaData());
Quantifier.ForEach quantifier = Quantifier.forEach(GroupExpressionRef.of(new FullUnorderedScanExpression(context.getMetaData().getRecordTypes().keySet())));
if (!context.getRecordTypes().isEmpty()) {
quantifier = Quantifier.forEach(GroupExpressionRef.of(new LogicalTypeFilterExpression(new HashSet<>(context.getRecordTypes()), quantifier)));
}
final SelectExpression selectExpression;
if (query.getFilter() != null) {
selectExpression = query.getFilter().expand(quantifier.getAlias()).buildSelectWithBase(quantifier);
} else {
selectExpression = GraphExpansion.empty().buildSelectWithBase(quantifier);
}
quantifier = Quantifier.forEach(GroupExpressionRef.of(selectExpression));
if (query.removesDuplicates()) {
quantifier = Quantifier.forEach(GroupExpressionRef.of(new LogicalDistinctExpression(quantifier)));
}
if (query.getSort() != null) {
quantifier = Quantifier.forEach(GroupExpressionRef.of(new LogicalSortExpression(query.getSort(), query.isSortReverse(), quantifier)));
} else {
quantifier = Quantifier.forEach(GroupExpressionRef.of(new LogicalSortExpression(null, false, quantifier)));
}
if (query.getRequiredResults() != null) {
final List<? extends Value> projectedValues = Value.fromKeyExpressions(query.getRequiredResults().stream().flatMap(keyExpression -> keyExpression.normalizeKeyForPositions().stream()).collect(ImmutableList.toImmutableList()), quantifier.getAlias());
quantifier = Quantifier.forEach(GroupExpressionRef.of(new LogicalProjectionExpression(projectedValues, quantifier)));
}
return quantifier.getRangesOver().get();
}
use of com.apple.foundationdb.record.query.plan.temp.expressions.FullUnorderedScanExpression in project fdb-record-layer by FoundationDB.
the class FullUnorderedExpressionToScanPlanRule method onMatch.
@Override
public void onMatch(@Nonnull PlannerRuleCall call) {
final FullUnorderedScanExpression fullUnorderedScanExpression = call.get(root);
call.yield(call.ref(new RecordQueryScanPlan(fullUnorderedScanExpression.getRecordTypes(), ScanComparisons.EMPTY, false)));
}
Aggregations