@Override public LogicalNode visitJoin(StringBuilder sb, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode joinNode, Stack<LogicalNode> stack) throws TajoException { stack.push(joinNode); sb.append("("); visit(sb, plan, block, joinNode.getLeftChild(), stack); sb.append(" ").append(getJoinNotation(joinNode.getJoinType())).append(" "); visit(sb, plan, block, joinNode.getRightChild(), stack); sb.append(")"); stack.pop(); return joinNode; }
@Override public RESULT visitJoin(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = visit(context, plan, block, node.getLeftChild(), stack); visit(context, plan, block, node.getRightChild(), stack); stack.pop(); return result; }
@Override public LogicalNode visitJoin(StringBuilder sb, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode joinNode, Stack<LogicalNode> stack) throws TajoException { stack.push(joinNode); sb.append("("); visit(sb, plan, block, joinNode.getLeftChild(), stack); sb.append(" ").append(getJoinNotation(joinNode.getJoinType())).append(" "); visit(sb, plan, block, joinNode.getRightChild(), stack); sb.append(")"); stack.pop(); return joinNode; }
@Override public RESULT visitJoin(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = visit(context, plan, block, node.getLeftChild(), stack); visit(context, plan, block, node.getRightChild(), stack); stack.pop(); return result; }
@Override public LogicalNode visitJoin(RelationNodeFinderContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); LogicalNode result = null; if (context.findMostLeft) { result = visit(context, plan, block, node.getLeftChild(), stack); } if (context.findMostRight) { result = visit(context, plan, block, node.getRightChild(), stack); } stack.pop(); return result; } }
@Override public LogicalNode visitJoin(RelationNodeFinderContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, JoinNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); LogicalNode result = null; if (context.findMostLeft) { result = visit(context, plan, block, node.getLeftChild(), stack); } if (context.findMostRight) { result = visit(context, plan, block, node.getRightChild(), stack); } stack.pop(); return result; } }
private PhysicalExec createBestFullOuterJoinPlan(TaskAttemptContext context, JoinNode plan, PhysicalExec leftExec, PhysicalExec rightExec) throws IOException { // The inner relation is always expected to be smaller than the outer relation. // (See GreedyHeuristicJoinOrderAlgorithm:::swapLeftAndRightIfNecessary(). // Thus, we need to evaluate only that the right table is able to be loaded or not. if (isHashOuterJoinFeasible(context, plan.getRightChild())) { return createFullOuterHashJoinPlan(context, plan, leftExec, rightExec); } else { return createFullOuterMergeJoinPlan(context, plan, leftExec, rightExec); } }
private PhysicalExec createBestFullOuterJoinPlan(TaskAttemptContext context, JoinNode plan, PhysicalExec leftExec, PhysicalExec rightExec) throws IOException { // The inner relation is always expected to be smaller than the outer relation. // (See GreedyHeuristicJoinOrderAlgorithm:::swapLeftAndRightIfNecessary(). // Thus, we need to evaluate only that the right table is able to be loaded or not. if (isHashOuterJoinFeasible(context, plan.getRightChild())) { return createFullOuterHashJoinPlan(context, plan, leftExec, rightExec); } else { return createFullOuterMergeJoinPlan(context, plan, leftExec, rightExec); } }
private PhysicalExec createBestLeftOuterJoinPlan(TaskAttemptContext context, JoinNode plan, PhysicalExec leftExec, PhysicalExec rightExec) throws IOException { if (isHashOuterJoinFeasible(context, plan.getRightChild())) { // we can implement left outer join using hash join, using the right operand as the build relation LOG.info("Left Outer Join (" + plan.getPID() +") chooses [Hash Join]."); return new HashLeftOuterJoinExec(context, plan, leftExec, rightExec); } else { //the right operand is too large, so we opt for merge join implementation LOG.info("Left Outer Join (" + plan.getPID() +") chooses [Merge Join]."); return createRightOuterMergeJoinPlan(context, plan, rightExec, leftExec); } }
private PhysicalExec createBestLeftOuterJoinPlan(TaskAttemptContext context, JoinNode plan, PhysicalExec leftExec, PhysicalExec rightExec) throws IOException { if (isHashOuterJoinFeasible(context, plan.getRightChild())) { // we can implement left outer join using hash join, using the right operand as the build relation LOG.info("Left Outer Join (" + plan.getPID() +") chooses [Hash Join]."); return new HashLeftOuterJoinExec(context, plan, leftExec, rightExec); } else { //the right operand is too large, so we opt for merge join implementation LOG.info("Left Outer Join (" + plan.getPID() +") chooses [Merge Join]."); return createRightOuterMergeJoinPlan(context, plan, rightExec, leftExec); } }
public static boolean isNonEquiThetaJoinQual(final LogicalPlan.QueryBlock block, final JoinNode joinNode, final EvalNode evalNode) { if (EvalTreeUtil.isJoinQual(block, joinNode.getLeftChild().getOutSchema(), joinNode.getRightChild().getOutSchema(), evalNode, true) && evalNode.getType() != EvalType.EQUAL) { return true; } else { return false; } }
private static boolean isNonEquiThetaJoinQual(final LogicalPlan.QueryBlock block, final JoinNode joinNode, final EvalNode evalNode) { if (EvalTreeUtil.isJoinQual(block, joinNode.getLeftChild().getOutSchema(), joinNode.getRightChild().getOutSchema(), evalNode, true) && evalNode.getType() != EvalType.EQUAL) { return true; } else { return false; } }
private static boolean isNonEquiThetaJoinQual(final LogicalPlan.QueryBlock block, final JoinNode joinNode, final EvalNode evalNode) { if (EvalTreeUtil.isJoinQual(block, joinNode.getLeftChild().getOutSchema(), joinNode.getRightChild().getOutSchema(), evalNode, true) && evalNode.getType() != EvalType.EQUAL) { return true; } else { return false; } }
public static boolean isNonEquiThetaJoinQual(final LogicalPlan.QueryBlock block, final JoinNode joinNode, final EvalNode evalNode) { if (EvalTreeUtil.isJoinQual(block, joinNode.getLeftChild().getOutSchema(), joinNode.getRightChild().getOutSchema(), evalNode, true) && evalNode.getType() != EvalType.EQUAL) { return true; } else { return false; } }
private PhysicalExec createBestInnerJoinPlan(TaskAttemptContext context, JoinNode plan, PhysicalExec leftExec, PhysicalExec rightExec) throws IOException { boolean inMemoryHashJoin = false; if (checkIfInMemoryInnerJoinIsPossible(context, plan.getLeftChild(), true) || checkIfInMemoryInnerJoinIsPossible(context, plan.getRightChild(), false)) { inMemoryHashJoin = true; } if (inMemoryHashJoin) { LOG.info("Join (" + plan.getPID() +") chooses [In-memory Hash Join]"); // returns two PhysicalExec. smaller one is 0, and larger one is 1. PhysicalExec [] orderedChilds = switchJoinSidesIfNecessary(context, plan, leftExec, rightExec); return new HashJoinExec(context, plan, orderedChilds[1], orderedChilds[0]); } else { return createMergeInnerJoin(context, plan, leftExec, rightExec); } }
private PhysicalExec createBestInnerJoinPlan(TaskAttemptContext context, JoinNode plan, PhysicalExec leftExec, PhysicalExec rightExec) throws IOException { boolean inMemoryHashJoin = false; if (checkIfInMemoryInnerJoinIsPossible(context, plan.getLeftChild(), true) || checkIfInMemoryInnerJoinIsPossible(context, plan.getRightChild(), false)) { inMemoryHashJoin = true; } if (inMemoryHashJoin) { LOG.info("Join (" + plan.getPID() +") chooses [In-memory Hash Join]"); // returns two PhysicalExec. smaller one is 0, and larger one is 1. PhysicalExec [] orderedChilds = switchJoinSidesIfNecessary(context, plan, leftExec, rightExec); return new HashJoinExec(context, plan, orderedChilds[1], orderedChilds[0]); } else { return createMergeInnerJoin(context, plan, leftExec, rightExec); } }
@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; }
private void assertJoinNode(LogicalNode node, String left, String right) { assertEquals(NodeType.JOIN, node.getType()); JoinNode joinNode = (JoinNode)node; if (left != null) { assertEquals(left, ((ScanNode)joinNode.getLeftChild()).getCanonicalName()); } else { assertEquals(NodeType.JOIN, joinNode.getLeftChild().getType()); } if (right != null) { assertEquals(right, ((ScanNode)joinNode.getRightChild()).getCanonicalName()); } else { assertEquals(NodeType.JOIN, joinNode.getRightChild().getType()); } } }
static void testQuery7(LogicalNode plan) { assertEquals(NodeType.PROJECTION, plan.getType()); ProjectionNode projNode = (ProjectionNode) plan; assertEquals(NodeType.GROUP_BY, projNode.getChild().getType()); GroupbyNode groupByNode = projNode.getChild(); assertEquals(NodeType.JOIN, groupByNode.getChild().getType()); JoinNode joinNode = groupByNode.getChild(); assertEquals(NodeType.SCAN, joinNode.getLeftChild().getType()); ScanNode leftNode = joinNode.getLeftChild(); assertEquals(IdentifierUtil.buildFQName(DEFAULT_DATABASE_NAME, "dept"), leftNode.getTableName()); assertEquals(NodeType.SCAN, joinNode.getRightChild().getType()); ScanNode rightNode = joinNode.getRightChild(); assertEquals(IdentifierUtil.buildFQName(DEFAULT_DATABASE_NAME, "score"), rightNode.getTableName()); }