use of com.apple.foundationdb.record.query.plan.temp.explain.Attribute in project fdb-record-layer by FoundationDB.
the class RecordQueryInUnionPlan method rewritePlannerGraph.
@Nonnull
@Override
public PlannerGraph rewritePlannerGraph(@Nonnull final List<? extends PlannerGraph> childGraphs) {
final PlannerGraph.Node root = new PlannerGraph.OperatorNodeWithInfo(this, NodeInfo.IN_UNION_OPERATOR, ImmutableList.of("COMPARE BY {{comparisonKey}}"), ImmutableMap.of("comparisonKey", Attribute.gml(comparisonKey.toString())));
final PlannerGraph graphForInner = Iterables.getOnlyElement(childGraphs);
final PlannerGraph.DataNodeWithInfo valuesNode = new PlannerGraph.DataNodeWithInfo(NodeInfo.VALUES_DATA, ImmutableList.of("VALUES({{values}}"), ImmutableMap.of("values", Attribute.gml(Objects.requireNonNull(valuesSources).stream().map(String::valueOf).map(Attribute::gml).collect(ImmutableList.toImmutableList()))));
final PlannerGraph.Edge fromValuesEdge = new PlannerGraph.Edge();
return PlannerGraph.builder(root).addGraph(graphForInner).addNode(valuesNode).addEdge(valuesNode, root, fromValuesEdge).addEdge(graphForInner.getRoot(), root, new PlannerGraph.Edge(ImmutableSet.of(fromValuesEdge))).build();
}
use of com.apple.foundationdb.record.query.plan.temp.explain.Attribute in project fdb-record-layer by FoundationDB.
the class RecordQueryScanPlan method rewritePlannerGraph.
/**
* Rewrite the planner graph for better visualization of a query scan plan.
* @param childGraphs planner graphs of children expression that already have been computed
* @return the rewritten planner graph that models scanned storage as a separate node that is connected to the
* actual scan plan node.
*/
@Nonnull
@Override
public PlannerGraph rewritePlannerGraph(@Nonnull List<? extends PlannerGraph> childGraphs) {
Verify.verify(childGraphs.isEmpty());
@Nullable final TupleRange tupleRange = comparisons.toTupleRangeWithoutContext();
final ImmutableList.Builder<String> detailsBuilder = ImmutableList.builder();
final ImmutableMap.Builder<String, Attribute> additionalAttributes = ImmutableMap.builder();
if (tupleRange != null) {
detailsBuilder.add("range: " + tupleRange.getLowEndpoint().toString(false) + "{{low}}, {{high}}" + tupleRange.getHighEndpoint().toString(true));
additionalAttributes.put("low", Attribute.gml(tupleRange.getLow() == null ? "-∞" : tupleRange.getLow().toString()));
additionalAttributes.put("high", Attribute.gml(tupleRange.getHigh() == null ? "∞" : tupleRange.getHigh().toString()));
} else {
detailsBuilder.add("comparisons: {{comparisons}}");
additionalAttributes.put("comparisons", Attribute.gml(comparisons.toString()));
}
if (reverse) {
detailsBuilder.add("direction: {{direction}}");
additionalAttributes.put("direction", Attribute.gml("reversed"));
}
final PlannerGraph.DataNodeWithInfo dataNodeWithInfo;
if (getRecordTypes() == null) {
dataNodeWithInfo = new PlannerGraph.DataNodeWithInfo(NodeInfo.BASE_DATA, ImmutableList.of("ALL"));
} else {
dataNodeWithInfo = new PlannerGraph.DataNodeWithInfo(NodeInfo.BASE_DATA, ImmutableList.of("record types: {{types}}"), ImmutableMap.of("types", Attribute.gml(getRecordTypes().stream().map(Attribute::gml).collect(ImmutableList.toImmutableList()))));
}
return PlannerGraph.fromNodeAndChildGraphs(new PlannerGraph.OperatorNodeWithInfo(this, NodeInfo.SCAN_OPERATOR, detailsBuilder.build(), additionalAttributes.build()), ImmutableList.of(PlannerGraph.fromNodeAndChildGraphs(dataNodeWithInfo, childGraphs)));
}
use of com.apple.foundationdb.record.query.plan.temp.explain.Attribute in project fdb-record-layer by FoundationDB.
the class RecordQueryInValuesJoinPlan method rewritePlannerGraph.
/**
* Rewrite the planner graph for better visualization of a query index plan.
* @param childGraphs planner graphs of children expression that already have been computed
* @return the rewritten planner graph that models this operator as a logical nested loop join
* joining an outer table of values in the IN clause to the correlated inner result of executing (usually)
* a index lookup for each bound outer value.
*/
@Nonnull
@Override
public PlannerGraph rewritePlannerGraph(@Nonnull List<? extends PlannerGraph> childGraphs) {
final PlannerGraph.Node root = new PlannerGraph.OperatorNodeWithInfo(this, NodeInfo.NESTED_LOOP_JOIN_OPERATOR);
final PlannerGraph graphForInner = Iterables.getOnlyElement(childGraphs);
final PlannerGraph.DataNodeWithInfo valuesNode = new PlannerGraph.DataNodeWithInfo(NodeInfo.VALUES_DATA, ImmutableList.of("VALUES({{values}}"), ImmutableMap.of("values", Attribute.gml(Objects.requireNonNull(getInListValues()).stream().map(String::valueOf).map(Attribute::gml).collect(ImmutableList.toImmutableList()))));
final PlannerGraph.Edge fromValuesEdge = new PlannerGraph.Edge();
return PlannerGraph.builder(root).addGraph(graphForInner).addNode(valuesNode).addEdge(valuesNode, root, fromValuesEdge).addEdge(graphForInner.getRoot(), root, new PlannerGraph.Edge(ImmutableSet.of(fromValuesEdge))).build();
}
Aggregations