public String toString() { StringBuilder sb = new StringBuilder("Join (type").append(joinSpec.getType()); if (hasJoinQual()) { sb.append(",filter=").append(joinSpec.getSingletonPredicate()); } sb.append(")"); return sb.toString(); } }
public String toString() { StringBuilder sb = new StringBuilder("Join (type").append(joinSpec.getType()); if (hasJoinQual()) { sb.append(",filter=").append(joinSpec.getSingletonPredicate()); } sb.append(")"); return sb.toString(); } }
@Override public LogicalNode visitJoin(Object context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode joinNode, Stack<LogicalNode> stack) throws TajoException { if (joinNode.hasJoinQual()) { joinNode.setJoinQual(evalRewriter.visit(null, joinNode.getJoinQual(), new Stack<EvalNode>())); } return null; } }
@Override public LogicalNode visitJoin(Object context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode joinNode, Stack<LogicalNode> stack) throws TajoException { if (joinNode.hasJoinQual()) { joinNode.setJoinQual(evalRewriter.visit(null, joinNode.getJoinQual(), new Stack<>())); } return null; } }
@Override public LogicalNode visitJoin(PlanShapeFixerContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { super.visitJoin(context, plan, block, node, stack); int rightChildNum = context.childNumbers.pop(); int leftChildNum = context.childNumbers.pop(); if (node.hasTargets()) { node.setTargets(sortTargets(node.getTargets())); } if (node.hasJoinQual()) { node.setJoinQual(sortQual(node.getJoinQual())); } context.childNumbers.push(rightChildNum + leftChildNum); return null; }
@Override public LogicalNode visitJoin(PlanShapeFixerContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { super.visitJoin(context, plan, block, node, stack); int rightChildNum = context.childNumbers.pop(); int leftChildNum = context.childNumbers.pop(); if (node.hasTargets()) { node.setTargets(sortTargets(node.getTargets())); } if (node.hasJoinQual()) { node.setJoinQual(sortQual(node.getJoinQual())); } context.childNumbers.push(rightChildNum + leftChildNum); return null; }
@Override public LogicalNode visitJoin(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { super.visitJoin(context, plan, block, node, stack); compileProjectableNode(context, node.getInSchema(), node); if (node.hasJoinQual()) { compileIfAbsent(context, node.getInSchema(), node.getJoinQual()); } return node; }
@Override public LogicalNode visitJoin(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { super.visitJoin(context, plan, block, node, stack); compileProjectableNode(context, node.getInSchema(), node); if (node.hasJoinQual()) { compileIfAbsent(context, node.getInSchema(), node.getJoinQual()); } return node; }
@Override public LogicalNode visitJoin(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { visit(context, plan, block, node.getLeftChild(), stack); visit(context, plan, block, node.getRightChild(), stack); if (node.hasJoinQual()) { ExprsVerifier.verify(context.state, node, node.getJoinQual()); } verifyProjectableOutputSchema(context, node); return node; }
@Override public LogicalNode visitJoin(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { visit(context, plan, block, node.getLeftChild(), stack); visit(context, plan, block, node.getRightChild(), stack); if (node.hasJoinQual()) { ExprsVerifier.verify(context.state, node, node.getJoinQual()); } verifyProjectableOutputSchema(context, node); return node; }
@Override public PlanString getPlanString() { PlanString planStr = new PlanString(this).appendTitle("(").appendTitle(joinSpec.getType().name()).appendTitle(")"); if (hasJoinQual()) { planStr.addExplan("Join Cond: " + joinSpec.getSingletonPredicate().toString()); } if (hasTargets()) { planStr.addExplan("target list: ").appendExplain(StringUtils.join(targets, ", ")); } planStr.addDetail("out schema: " + getOutSchema()); planStr.addDetail("in schema: " + getInSchema()); return planStr; }
@Override public LogicalNode visitJoin(CostContext joinGraphContext, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode joinNode, Stack<LogicalNode> stack) throws TajoException { super.visitJoin(joinGraphContext, plan, block, joinNode, stack); double filterFactor = 1; if (joinNode.hasJoinQual()) { EvalNode [] quals = AlgebraicUtil.toConjunctiveNormalFormArray(joinNode.getJoinQual()); filterFactor = Math.pow(GreedyHeuristicJoinOrderAlgorithm.DEFAULT_SELECTION_FACTOR, quals.length); } if (joinNode.getLeftChild() instanceof RelationNode) { joinGraphContext.accumulatedCost = getCost(joinNode.getLeftChild()) * getCost(joinNode.getRightChild()) * filterFactor; } else { joinGraphContext.accumulatedCost = joinGraphContext.accumulatedCost + (joinGraphContext.accumulatedCost * getCost(joinNode.getRightChild()) * filterFactor); } return joinNode; } }
@Override public LogicalNode visitJoin(CostContext joinGraphContext, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode joinNode, Stack<LogicalNode> stack) throws TajoException { super.visitJoin(joinGraphContext, plan, block, joinNode, stack); double filterFactor = 1; if (joinNode.hasJoinQual()) { EvalNode [] quals = AlgebraicUtil.toConjunctiveNormalFormArray(joinNode.getJoinQual()); filterFactor = Math.pow(GreedyHeuristicJoinOrderAlgorithm.DEFAULT_SELECTION_FACTOR, quals.length); } if (joinNode.getLeftChild() instanceof RelationNode) { joinGraphContext.accumulatedCost = getCost((RelationNode)joinNode.getLeftChild()) * getCost((LogicalNode)joinNode.getRightChild())* filterFactor; } else { joinGraphContext.accumulatedCost = joinGraphContext.accumulatedCost + (joinGraphContext.accumulatedCost * getCost((RelationNode)joinNode.getRightChild()) * filterFactor); } return joinNode; } }
public RightOuterMergeJoinExec(TaskAttemptContext context, JoinNode plan, PhysicalExec outer, PhysicalExec inner, SortSpec[] outerSortKey, SortSpec[] innerSortKey) { super(context, plan, outer, inner); Preconditions.checkArgument(plan.hasJoinQual(), "Sort-merge join is only used for the equi-join, " + "but there is no join condition"); final int INITIAL_TUPLE_SLOT = context.getQueryContext().getInt(SessionVars.JOIN_HASH_TABLE_SIZE); this.leftTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); this.innerTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); SortSpec[][] sortSpecs = new SortSpec[2][]; sortSpecs[0] = outerSortKey; sortSpecs[1] = innerSortKey; this.joinComparator = new JoinTupleComparator(outer.getSchema(), inner.getSchema(), sortSpecs); this.tupleComparator = PhysicalPlanUtil.getComparatorsFromJoinQual( plan.getJoinQual(), outer.getSchema(), inner.getSchema()); leftNumCols = outer.getSchema().size(); nullPaddedTuple = NullTuple.create(leftNumCols); }
public RightOuterMergeJoinExec(TaskAttemptContext context, JoinNode plan, PhysicalExec outer, PhysicalExec inner, SortSpec[] outerSortKey, SortSpec[] innerSortKey) { super(context, plan, outer, inner); Preconditions.checkArgument(plan.hasJoinQual(), "Sort-merge join is only used for the equi-join, " + "but there is no join condition"); final int INITIAL_TUPLE_SLOT = context.getQueryContext().getInt(SessionVars.JOIN_HASH_TABLE_SIZE); this.leftTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); this.innerTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); SortSpec[][] sortSpecs = new SortSpec[2][]; sortSpecs[0] = outerSortKey; sortSpecs[1] = innerSortKey; this.joinComparator = new JoinTupleComparator(outer.getSchema(), inner.getSchema(), sortSpecs); this.tupleComparator = PhysicalPlanUtil.getComparatorsFromJoinQual( plan.getJoinQual(), outer.getSchema(), inner.getSchema()); leftNumCols = outer.getSchema().size(); nullPaddedTuple = NullTuple.create(leftNumCols); }
@Override public PlanString getPlanString() { PlanString planStr = new PlanString(this).appendTitle("(").appendTitle(joinSpec.getType().name()).appendTitle(")"); if (hasJoinQual()) { planStr.addExplan("Join Cond: " + joinSpec.getSingletonPredicate().toString()); } if (hasTargets()) { planStr.addExplan("target list: "); boolean first = true; for (Target target : targets) { if (!first) { planStr.appendExplain(", "); } planStr.appendExplain(target.toString()); first = false; } } planStr.addDetail("out schema: " + getOutSchema()); planStr.addDetail("in schema: " + getInSchema()); return planStr; }
public MergeJoinExec(TaskAttemptContext context, JoinNode plan, PhysicalExec outer, PhysicalExec inner, SortSpec[] outerSortKey, SortSpec[] innerSortKey) { super(context, plan, outer, inner); Preconditions.checkArgument(plan.hasJoinQual(), "Sort-merge join is only used for the equi-join, " + "but there is no join condition"); final int INITIAL_TUPLE_SLOT = context.getQueryContext().getInt(SessionVars.JOIN_HASH_TABLE_SIZE); this.outerTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); this.innerTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); SortSpec[][] sortSpecs = new SortSpec[2][]; sortSpecs[0] = outerSortKey; sortSpecs[1] = innerSortKey; this.joincomparator = new JoinTupleComparator(outer.getSchema(), inner.getSchema(), sortSpecs); this.tupleComparator = PhysicalPlanUtil.getComparatorsFromJoinQual( plan.getJoinQual(), outer.getSchema(), inner.getSchema()); this.outerIterator = outerTupleSlots.iterator(); this.innerIterator = innerTupleSlots.iterator(); prevOuterTuple = new VTuple(leftChild.getSchema().size()); prevInnerTuple = new VTuple(rightChild.getSchema().size()); }
public MergeJoinExec(TaskAttemptContext context, JoinNode plan, PhysicalExec outer, PhysicalExec inner, SortSpec[] outerSortKey, SortSpec[] innerSortKey) { super(context, plan, outer, inner); Preconditions.checkArgument(plan.hasJoinQual(), "Sort-merge join is only used for the equi-join, " + "but there is no join condition"); final int INITIAL_TUPLE_SLOT = context.getQueryContext().getInt(SessionVars.JOIN_HASH_TABLE_SIZE); this.outerTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); this.innerTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); SortSpec[][] sortSpecs = new SortSpec[2][]; sortSpecs[0] = outerSortKey; sortSpecs[1] = innerSortKey; this.joincomparator = new JoinTupleComparator(outer.getSchema(), inner.getSchema(), sortSpecs); this.tupleComparator = PhysicalPlanUtil.getComparatorsFromJoinQual( plan.getJoinQual(), outer.getSchema(), inner.getSchema()); this.outerIterator = outerTupleSlots.iterator(); this.innerIterator = innerTupleSlots.iterator(); prevOuterTuple = new VTuple(leftChild.getSchema().size()); prevInnerTuple = new VTuple(rightChild.getSchema().size()); }
public MergeFullOuterJoinExec(TaskAttemptContext context, JoinNode plan, PhysicalExec leftChild, PhysicalExec rightChild, SortSpec[] leftSortKey, SortSpec[] rightSortKey) { super(context, plan, leftChild, rightChild); Preconditions.checkArgument(plan.hasJoinQual(), "Sort-merge join is only used for the equi-join, " + "but there is no join condition"); final int INITIAL_TUPLE_SLOT = context.getQueryContext().getInt(SessionVars.JOIN_HASH_TABLE_SIZE); this.leftTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); this.rightTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); SortSpec[][] sortSpecs = new SortSpec[2][]; sortSpecs[0] = leftSortKey; sortSpecs[1] = rightSortKey; this.joincomparator = new JoinTupleComparator(leftChild.getSchema(), rightChild.getSchema(), sortSpecs); this.tupleComparator = PhysicalPlanUtil.getComparatorsFromJoinQual( plan.getJoinQual(), leftChild.getSchema(), rightChild.getSchema()); leftNumCols = leftChild.getSchema().size(); rightNumCols = rightChild.getSchema().size(); prevLeftTuple = new VTuple(leftChild.getSchema().size()); prevRightTuple = new VTuple(rightChild.getSchema().size()); leftNullTuple = NullTuple.create(leftNumCols); rightNullTuple = NullTuple.create(rightNumCols); }
public MergeFullOuterJoinExec(TaskAttemptContext context, JoinNode plan, PhysicalExec leftChild, PhysicalExec rightChild, SortSpec[] leftSortKey, SortSpec[] rightSortKey) { super(context, plan, leftChild, rightChild); Preconditions.checkArgument(plan.hasJoinQual(), "Sort-merge join is only used for the equi-join, " + "but there is no join condition"); final int INITIAL_TUPLE_SLOT = context.getQueryContext().getInt(SessionVars.JOIN_HASH_TABLE_SIZE); this.leftTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); this.rightTupleSlots = new TupleList(INITIAL_TUPLE_SLOT); SortSpec[][] sortSpecs = new SortSpec[2][]; sortSpecs[0] = leftSortKey; sortSpecs[1] = rightSortKey; this.joincomparator = new JoinTupleComparator(leftChild.getSchema(), rightChild.getSchema(), sortSpecs); this.tupleComparator = PhysicalPlanUtil.getComparatorsFromJoinQual( plan.getJoinQual(), leftChild.getSchema(), rightChild.getSchema()); leftNumCols = leftChild.getSchema().size(); rightNumCols = rightChild.getSchema().size(); prevLeftTuple = new VTuple(leftChild.getSchema().size()); prevRightTuple = new VTuple(rightChild.getSchema().size()); leftNullTuple = NullTuple.create(leftNumCols); rightNullTuple = NullTuple.create(rightNumCols); }