This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 4e566e40cf08a43caf60e4e1cab34e964b56d422 Author: Ali Alsuliman <[email protected]> AuthorDate: Mon Jan 9 21:38:20 2023 -0800 [ASTERIXDB-3097][OTH] Print hash join inputs in reverse - user model changes: no - storage format changes: no - interface changes: no Details: Change the JSON plan format so that for a hash join the build side is placed at index 0 of the hash join inputs array. Also, add "build-side" field to designate the index of the build side in the inputs array. Change-Id: I9c5000f1ff01cc8e2290d16105cb87595065fc1a Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17308 Integration-Tests: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Reviewed-by: Ali Alsuliman <[email protected]> Reviewed-by: Wail Alkowaileet <[email protected]> Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17342 Reviewed-by: Michael Blow <[email protected]> Tested-by: Michael Blow <[email protected]> --- .../LogicalOperatorPrettyPrintVisitorJson.java | 44 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/prettyprint/LogicalOperatorPrettyPrintVisitorJson.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/prettyprint/LogicalOperatorPrettyPrintVisitorJson.java index b1cdeb12d7..661e0cfad6 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/prettyprint/LogicalOperatorPrettyPrintVisitorJson.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/prettyprint/LogicalOperatorPrettyPrintVisitorJson.java @@ -36,8 +36,10 @@ import org.apache.hyracks.algebricks.core.algebra.base.IPhysicalOperator; import org.apache.hyracks.algebricks.core.algebra.base.LogicalOperatorTag; import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable; import org.apache.hyracks.algebricks.core.algebra.base.OperatorAnnotations; +import org.apache.hyracks.algebricks.core.algebra.base.PhysicalOperatorTag; import org.apache.hyracks.algebricks.core.algebra.expressions.IAlgebricksConstantValue; import org.apache.hyracks.algebricks.core.algebra.metadata.IProjectionInfo; +import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractBinaryJoinOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractOperatorWithNestedPlans; import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractUnnestMapOperator; @@ -206,12 +208,9 @@ public class LogicalOperatorPrettyPrintVisitorJson extends AbstractLogicalOperat generateCardCostFields(op); - if (printInputs && !op.getInputs().isEmpty()) { - jsonGenerator.writeArrayFieldStart("inputs"); - for (Mutable<ILogicalOperator> k : op.getInputs()) { - printOperatorImpl((AbstractLogicalOperator) k.getValue(), printInputs, printOptimizerEstimates); - } - jsonGenerator.writeEndArray(); + List<Mutable<ILogicalOperator>> inputs = op.getInputs(); + if (printInputs && !inputs.isEmpty()) { + printInputs(op, inputs, printOptimizerEstimates); } jsonGenerator.writeEndObject(); if (nestPlanInPlanField) { @@ -222,6 +221,22 @@ public class LogicalOperatorPrettyPrintVisitorJson extends AbstractLogicalOperat } } + private void printInputs(AbstractLogicalOperator op, List<Mutable<ILogicalOperator>> inputs, + boolean printOptimizerEstimates) throws IOException, AlgebricksException { + jsonGenerator.writeArrayFieldStart("inputs"); + if (printInputsInReverse(op)) { + for (int i = inputs.size() - 1; i >= 0; i--) { + Mutable<ILogicalOperator> inOp = inputs.get(i); + printOperatorImpl((AbstractLogicalOperator) inOp.getValue(), true, printOptimizerEstimates); + } + } else { + for (Mutable<ILogicalOperator> inOp : inputs) { + printOperatorImpl((AbstractLogicalOperator) inOp.getValue(), true, printOptimizerEstimates); + } + } + jsonGenerator.writeEndArray(); + } + private boolean nestPlanInPlanField(AbstractLogicalOperator op, boolean printOptimizerEstimates) throws IOException { if (op.getOperatorTag() == LogicalOperatorTag.DISTRIBUTE_RESULT && printOptimizerEstimates) { @@ -371,6 +386,7 @@ public class LogicalOperatorPrettyPrintVisitorJson extends AbstractLogicalOperat try { jsonGenerator.writeStringField(OPERATOR_FIELD, "join"); writeStringFieldExpression(CONDITION_FIELD, op.getCondition(), indent); + writeBuildSide(op); return null; } catch (IOException e) { throw AlgebricksException.create(ErrorCode.ERROR_PRINTING_PLAN, e, String.valueOf(e)); @@ -385,6 +401,7 @@ public class LogicalOperatorPrettyPrintVisitorJson extends AbstractLogicalOperat if (op.getMissingValue().isNull()) { writeNullField(MISSING_VALUE_FIELD); } + writeBuildSide(op); return null; } catch (IOException e) { throw AlgebricksException.create(ErrorCode.ERROR_PRINTING_PLAN, e, String.valueOf(e)); @@ -936,6 +953,21 @@ public class LogicalOperatorPrettyPrintVisitorJson extends AbstractLogicalOperat } } + private void writeBuildSide(AbstractBinaryJoinOperator op) throws IOException { + int buildInputIndex = printInputsInReverse(op) ? 0 : 1; + jsonGenerator.writeNumberField("build-side", buildInputIndex); + } + + private static boolean printInputsInReverse(AbstractLogicalOperator op) { + return isHashJoin(op); + } + + private static boolean isHashJoin(AbstractLogicalOperator op) { + IPhysicalOperator pOp = op.getPhysicalOperator(); + return pOp != null && (pOp.getOperatorTag() == PhysicalOperatorTag.IN_MEMORY_HASH_JOIN + || pOp.getOperatorTag() == PhysicalOperatorTag.HYBRID_HASH_JOIN); + } + private String getIndexOpString(Kind opKind) { switch (opKind) { case DELETE:
