@Override public RESULT visitUnion(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = null; if (plan != null) { LogicalPlan.QueryBlock leftBlock = plan.getBlock(node.getLeftChild()); result = visit(context, plan, leftBlock, leftBlock.getRoot(), stack); LogicalPlan.QueryBlock rightBlock = plan.getBlock(node.getRightChild()); visit(context, plan, rightBlock, rightBlock.getRoot(), stack); } else { result = visit(context, null, null, node.getLeftChild(), stack); visit(context, null, null, node.getRightChild(), stack); } stack.pop(); return result; }
private static UnionNode convertUnion(Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { PlanProto.UnionNode unionProto = protoNode.getUnion(); UnionNode union = new UnionNode(protoNode.getNodeId()); union.setInSchema(convertSchema(protoNode.getInSchema())); union.setOutSchema(convertSchema(protoNode.getOutSchema())); union.setLeftChild(nodeMap.get(unionProto.getLeftChildSeq())); union.setRightChild(nodeMap.get(unionProto.getRightChildSeq())); return union; }
@Override public LogicalNode visitUnion(ProcessorContext ctx, Stack<Expr> stack, SetOperation expr) throws TajoException { super.visitUnion(ctx, stack, expr); UnionNode node = getNodeFromExpr(ctx.planContext.getPlan(), expr); LogicalNode child = getNonRelationListExpr(ctx.planContext.getPlan(), expr.getLeft()); node.setInSchema(child.getOutSchema()); node.setOutSchema(node.getInSchema()); return node; }
UnionNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); LogicalPlan.QueryBlock leftQueryBlock = plan.getBlock(node.getLeftChild()); LogicalNode leftChild = visit(context, plan, leftQueryBlock, leftQueryBlock.getRoot(), stack); LogicalPlan.QueryBlock rightQueryBlock = plan.getBlock(node.getRightChild()); LogicalNode rightChild = visit(context, plan, rightQueryBlock, rightQueryBlock.getRoot(), stack); stack.pop(); context.execBlockMap.put(node.getPID(), execBlock);
@Test public final void testUnionPlan() throws IOException, TajoException, CloneNotSupportedException { FileFragment[] frags = FileTablespace.splitNG(conf, "default.employee", employee.getMeta(), new Path(employee.getUri()), Integer.MAX_VALUE); Path workDir = CommonTestingUtil.getTestDir(TajoTestingCluster.DEFAULT_TEST_DIRECTORY + "/testUnionPlan"); TaskAttemptContext ctx = new TaskAttemptContext(new QueryContext(conf), LocalTajoTestingUtility.newTaskAttemptId(masterPlan), new FileFragment[] { frags[0] }, workDir); ctx.setEnforcer(new Enforcer()); Expr context = analyzer.parse(QUERIES[0]); LogicalPlan plan = planner.createPlan(defaultContext, context); LogicalNode rootNode = optimizer.optimize(plan); LogicalRootNode root = (LogicalRootNode) rootNode; UnionNode union = plan.createNode(UnionNode.class); union.setLeftChild((LogicalNode) root.getChild().clone()); union.setRightChild((LogicalNode) root.getChild().clone()); root.setChild(union); PhysicalPlanner phyPlanner = new PhysicalPlannerImpl(conf); PhysicalExec exec = phyPlanner.createPlan(ctx, root); int count = 0; exec.init(); while(exec.next() != null) { count++; } exec.close(); assertEquals(200, count); }
UnionNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); LogicalPlan.QueryBlock leftQueryBlock = plan.getBlock(node.getLeftChild()); LogicalNode leftChild = visit(context, plan, leftQueryBlock, leftQueryBlock.getRoot(), stack); LogicalPlan.QueryBlock rightQueryBlock = plan.getBlock(node.getRightChild()); LogicalNode rightChild = visit(context, plan, rightQueryBlock, rightQueryBlock.getRoot(), stack); stack.pop(); context.execBlockMap.put(node.getPID(), execBlock);
private static UnionNode convertUnion(Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { PlanProto.UnionNode unionProto = protoNode.getUnion(); UnionNode union = new UnionNode(protoNode.getNodeId()); union.setInSchema(convertSchema(protoNode.getInSchema())); union.setOutSchema(convertSchema(protoNode.getOutSchema())); union.setLeftChild(nodeMap.get(unionProto.getLeftChildSeq())); union.setRightChild(nodeMap.get(unionProto.getRightChildSeq())); return union; }
@Override public RESULT visitUnion(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = null; if (plan != null) { LogicalPlan.QueryBlock leftBlock = plan.getBlock(node.getLeftChild()); result = visit(context, plan, leftBlock, leftBlock.getRoot(), stack); LogicalPlan.QueryBlock rightBlock = plan.getBlock(node.getRightChild()); visit(context, plan, rightBlock, rightBlock.getRoot(), stack); } else { result = visit(context, null, null, node.getLeftChild(), stack); visit(context, null, null, node.getRightChild(), stack); } stack.pop(); return result; }
@Override public LogicalNode visitUnion(ProcessorContext ctx, Stack<Expr> stack, SetOperation expr) throws TajoException { super.visitUnion(ctx, stack, expr); UnionNode node = getNodeFromExpr(ctx.planContext.getPlan(), expr); LogicalNode child = getNonRelationListExpr(ctx.planContext.getPlan(), expr.getLeft()); node.setInSchema(child.getOutSchema()); node.setOutSchema(node.getInSchema()); return node; }
@Override public LogicalNode visitUnion(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, SetOperation expr) throws TajoException { LogicalPlan.QueryBlock leftBlock = ctx.getPlan().newQueryBlock(); LogicalPlanner.PlanContext leftContext = new LogicalPlanner.PlanContext(ctx, leftBlock); LogicalNode leftChild = visit(leftContext, new Stack<>(), expr.getLeft()); leftBlock.setRoot(leftChild); ctx.getQueryBlock().registerExprWithNode(expr.getLeft(), leftChild); LogicalPlan.QueryBlock rightBlock = ctx.getPlan().newQueryBlock(); LogicalPlanner.PlanContext rightContext = new LogicalPlanner.PlanContext(ctx, rightBlock); LogicalNode rightChild = visit(rightContext, new Stack<>(), expr.getRight()); rightBlock.setRoot(rightChild); ctx.getQueryBlock().registerExprWithNode(expr.getRight(), rightChild); UnionNode unionNode = new UnionNode(ctx.getPlan().newPID()); unionNode.setLeftChild(leftChild); unionNode.setRightChild(rightChild); unionNode.setInSchema(leftChild.getOutSchema()); unionNode.setOutSchema(leftChild.getOutSchema()); unionNode.setDistinct(expr.isDistinct()); return unionNode; }
@Override public LogicalNode visitUnion(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode unionNode, Stack<LogicalNode> stack) throws TajoException { LogicalNode leftNode = unionNode.getLeftChild(); List<EvalNode> origins = new ArrayList<>(); origins.addAll(context.pushingDownFilters); // transformed -> pushingDownFilters Map<EvalNode, EvalNode> transformedMap = transformEvalsWidthByPassNode(origins, plan, block, unionNode, leftNode); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(leftNode)); if (!context.pushingDownFilters.isEmpty()) { errorFilterPushDown(plan, leftNode, context); } LogicalNode rightNode = unionNode.getRightChild(); transformedMap = transformEvalsWidthByPassNode(origins, plan, block, unionNode, rightNode); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(rightNode), rightNode, stack); if (!context.pushingDownFilters.isEmpty()) { errorFilterPushDown(plan, rightNode, context); } // notify all filter matched to upper context.pushingDownFilters.clear(); return unionNode; }
@Override public LogicalNode visitUnion(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, SetOperation expr) throws TajoException { LogicalPlan.QueryBlock leftBlock = ctx.getPlan().newQueryBlock(); LogicalPlanner.PlanContext leftContext = new LogicalPlanner.PlanContext(ctx, leftBlock); LogicalNode leftChild = visit(leftContext, new Stack<Expr>(), expr.getLeft()); leftBlock.setRoot(leftChild); ctx.getQueryBlock().registerExprWithNode(expr.getLeft(), leftChild); LogicalPlan.QueryBlock rightBlock = ctx.getPlan().newQueryBlock(); LogicalPlanner.PlanContext rightContext = new LogicalPlanner.PlanContext(ctx, rightBlock); LogicalNode rightChild = visit(rightContext, new Stack<Expr>(), expr.getRight()); rightBlock.setRoot(rightChild); ctx.getQueryBlock().registerExprWithNode(expr.getRight(), rightChild); UnionNode unionNode = new UnionNode(ctx.getPlan().newPID()); unionNode.setLeftChild(leftChild); unionNode.setRightChild(rightChild); unionNode.setInSchema(leftChild.getOutSchema()); unionNode.setOutSchema(leftChild.getOutSchema()); unionNode.setDistinct(expr.isDistinct()); return unionNode; }
@Override public LogicalNode visitUnion(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node, Stack<LogicalNode> stack) throws TajoException { LogicalPlan.QueryBlock leftBlock = plan.getBlock(node.getLeftChild()); LogicalPlan.QueryBlock rightBlock = plan.getBlock(node.getRightChild()); Context leftContext = new Context(plan, PlannerUtil.toQualifiedFieldNames(context.requiredSet, leftBlock.getName())); Context rightContext = new Context(plan, PlannerUtil.toQualifiedFieldNames(context.requiredSet, rightBlock.getName())); stack.push(node); visit(leftContext, plan, leftBlock, leftBlock.getRoot(), new Stack<>()); visit(rightContext, plan, rightBlock, rightBlock.getRoot(), new Stack<>()); stack.pop(); return node; }
unionNode.setLeftChild(left); unionNode.setRightChild(GlobalPlanner.buildInputExecutor(plan.getLogicalPlan(), plan.getChannel(unionScans.get(i), current.getId()))); unionNode.setInSchema(left.getOutSchema()); unionNode.setOutSchema(left.getOutSchema()); topUnion = unionNode; left = unionNode;
@Override public LogicalNode visitUnion(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode node, Stack<LogicalNode> stack) throws TajoException { LogicalPlan.QueryBlock leftBlock = plan.getBlock(node.getLeftChild()); LogicalPlan.QueryBlock rightBlock = plan.getBlock(node.getRightChild()); Context leftContext = new Context(plan, PlannerUtil.toQualifiedFieldNames(context.requiredSet, leftBlock.getName())); Context rightContext = new Context(plan, PlannerUtil.toQualifiedFieldNames(context.requiredSet, rightBlock.getName())); stack.push(node); visit(leftContext, plan, leftBlock, leftBlock.getRoot(), new Stack<LogicalNode>()); visit(rightContext, plan, rightBlock, rightBlock.getRoot(), new Stack<LogicalNode>()); stack.pop(); return node; }
unionNode.setLeftChild(left); unionNode.setRightChild(GlobalPlanner.buildInputExecutor(plan.getLogicalPlan(), plan.getChannel(unionScans.get(i), current.getId()))); unionNode.setInSchema(left.getOutSchema()); unionNode.setOutSchema(left.getOutSchema()); topUnion = unionNode; left = unionNode;
@Override public LogicalNode visitUnion(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnionNode unionNode, Stack<LogicalNode> stack) throws TajoException { LogicalNode leftNode = unionNode.getLeftChild(); List<EvalNode> origins = TUtil.newList(context.pushingDownFilters); // transformed -> pushingDownFilters Map<EvalNode, EvalNode> transformedMap = transformEvalsWidthByPassNode(origins, plan, block, unionNode, leftNode); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(leftNode)); if (!context.pushingDownFilters.isEmpty()) { errorFilterPushDown(plan, leftNode, context); } LogicalNode rightNode = unionNode.getRightChild(); transformedMap = transformEvalsWidthByPassNode(origins, plan, block, unionNode, rightNode); context.setFiltersTobePushed(transformedMap.keySet()); visit(context, plan, plan.getBlock(rightNode), rightNode, stack); if (!context.pushingDownFilters.isEmpty()) { errorFilterPushDown(plan, rightNode, context); } // notify all filter matched to upper context.pushingDownFilters.clear(); return unionNode; }
UnionNode unionNode = (UnionNode) logicalNode; stack.push(unionNode); leftExec = createPlanRecursive(ctx, unionNode.getLeftChild(), stack); rightExec = createPlanRecursive(ctx, unionNode.getRightChild(), stack); stack.pop(); return new UnionExec(ctx, leftExec, rightExec);
UnionNode unionNode = (UnionNode) logicalNode; stack.push(unionNode); leftExec = createPlanRecursive(ctx, unionNode.getLeftChild(), stack); rightExec = createPlanRecursive(ctx, unionNode.getRightChild(), stack); stack.pop(); return new UnionExec(ctx, leftExec, rightExec);
} else if (node instanceof UnionNode) { UnionNode binaryNode = (UnionNode) node; return estimateOutputVolumeInternal(binaryNode.getLeftChild()) + estimateOutputVolumeInternal(binaryNode.getRightChild()); } else if (node instanceof JoinNode) { JoinNode joinNode = (JoinNode) node;