>From Ali Alsuliman <[email protected]>: Ali Alsuliman has submitted this change. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17308 )
Change subject: [ASTERIXDB-3097][OTH] Print hash join inputs in reverse ...................................................................... [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]> --- M hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/prettyprint/LogicalOperatorPrettyPrintVisitorJson.java 1 file changed, 62 insertions(+), 6 deletions(-) Approvals: Wail Alkowaileet: Looks good to me, approved Ali Alsuliman: Looks good to me, but someone else must approve Jenkins: Verified; Verified Objections: Anon. E. Moose #1000171: Violations found 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 5198065..27283f5 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 @@ -38,8 +38,10 @@ 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; @@ -222,12 +224,9 @@ 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) { @@ -238,6 +237,22 @@ } } + 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) { @@ -387,6 +402,7 @@ 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)); @@ -401,6 +417,7 @@ 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)); @@ -958,6 +975,21 @@ } } + 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: -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17308 To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Change-Id: I9c5000f1ff01cc8e2290d16105cb87595065fc1a Gerrit-Change-Number: 17308 Gerrit-PatchSet: 2 Gerrit-Owner: Ali Alsuliman <[email protected]> Gerrit-Reviewer: Ali Alsuliman <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Glenn Galvizo <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Till Westmann <[email protected]> Gerrit-Reviewer: Vijay Sarathy <[email protected]> Gerrit-Reviewer: Wail Alkowaileet <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-MessageType: merged
