/** * Create a LogicalNode instance for a type. Each a LogicalNode instance is given an unique plan node id (PID). * * @param theClass The class to be created * @return a LogicalNode instance identified by an unique plan node id (PID). */ public <T extends LogicalNode> T createNode(Class<T> theClass) { try { Constructor<T> ctor = theClass.getConstructor(int.class); return ctor.newInstance(newPID()); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Create a LogicalNode instance for a type. Each a LogicalNode instance is given an unique plan node id (PID). * * @param theClass The class to be created * @return a LogicalNode instance identified by an unique plan node id (PID). */ public <T extends LogicalNode> T createNode(Class<T> theClass) { try { Constructor<T> ctor = theClass.getConstructor(int.class); return ctor.newInstance(newPID()); } catch (Exception e) { throw new RuntimeException(e); } }
public static <T extends LogicalNode> T clone(LogicalPlan plan, LogicalNode node) { try { T copy = (T) node.clone(); if (plan == null) { copy.setPID(-1); } else { copy.setPID(plan.newPID()); if (node instanceof DistinctGroupbyNode) { DistinctGroupbyNode dNode = (DistinctGroupbyNode)copy; for (GroupbyNode eachNode: dNode.getSubPlans()) { eachNode.setPID(plan.newPID()); } } } return copy; } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } }
public static <T extends LogicalNode> T clone(LogicalPlan plan, LogicalNode node) { try { T copy = (T) node.clone(); if (plan == null) { copy.setPID(-1); } else { copy.setPID(plan.newPID()); if (node instanceof DistinctGroupbyNode) { DistinctGroupbyNode dNode = (DistinctGroupbyNode)copy; for (GroupbyNode eachNode: dNode.getSubPlans()) { eachNode.setPID(plan.newPID()); } } } return copy; } catch (CloneNotSupportedException e) { throw new RuntimeException(e); } }
public LogicalNode visitInsert(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, Insert expr) throws TajoException { LogicalNode child = super.visitInsert(ctx, stack, expr); InsertNode insertNode = new InsertNode(ctx.getPlan().newPID()); insertNode.setInSchema(child.getOutSchema()); insertNode.setOutSchema(child.getOutSchema()); return insertNode; }
public LogicalNode visitInsert(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, Insert expr) throws TajoException { LogicalNode child = super.visitInsert(ctx, stack, expr); InsertNode insertNode = new InsertNode(ctx.getPlan().newPID()); insertNode.setInSchema(child.getOutSchema()); insertNode.setOutSchema(child.getOutSchema()); return insertNode; }
DistinctGroupbyNodeBuildInfo buildInfo = distinctNodeBuildInfos.get(groupbyMapKey); if (buildInfo == null) { GroupbyNode distinctGroupbyNode = new GroupbyNode(context.getPlan().getLogicalPlan().newPID()); buildInfo = new DistinctGroupbyNodeBuildInfo(distinctGroupbyNode); distinctNodeBuildInfos.put(groupbyMapKey, buildInfo); GroupbyNode otherGroupbyNode = new GroupbyNode(context.getPlan().getLogicalPlan().newPID()); DistinctGroupbyNode baseDistinctNode = new DistinctGroupbyNode(context.getPlan().getLogicalPlan().newPID()); baseDistinctNode.setTargets(groupbyNode.getTargets()); baseDistinctNode.setGroupingColumns(groupbyNode.getGroupingColumns());
DistinctGroupbyNodeBuildInfo buildInfo = distinctNodeBuildInfos.get(groupbyMapKey); if (buildInfo == null) { GroupbyNode distinctGroupbyNode = new GroupbyNode(context.getPlan().getLogicalPlan().newPID()); buildInfo = new DistinctGroupbyNodeBuildInfo(distinctGroupbyNode); distinctNodeBuildInfos.put(groupbyMapKey, buildInfo); GroupbyNode otherGroupbyNode = new GroupbyNode(context.getPlan().getLogicalPlan().newPID()); DistinctGroupbyNode baseDistinctNode = new DistinctGroupbyNode(context.getPlan().getLogicalPlan().newPID()); baseDistinctNode.setTargets(baseGroupByTargets); baseDistinctNode.setGroupingColumns(groupbyNode.getGroupingColumns());
DistinctGroupbyNodeBuildInfo buildInfo = distinctNodeBuildInfos.get(groupbyMapKey); if (buildInfo == null) { GroupbyNode distinctGroupbyNode = new GroupbyNode(context.getPlan().getLogicalPlan().newPID()); buildInfo = new DistinctGroupbyNodeBuildInfo(distinctGroupbyNode); distinctNodeBuildInfos.put(groupbyMapKey, buildInfo); GroupbyNode otherGroupbyNode = new GroupbyNode(context.getPlan().getLogicalPlan().newPID()); DistinctGroupbyNode baseDistinctNode = new DistinctGroupbyNode(context.getPlan().getLogicalPlan().newPID()); baseDistinctNode.setTargets(baseGroupByTargets.toArray(new Target[]{})); baseDistinctNode.setGroupingColumns(groupbyNode.getGroupingColumns());
DistinctGroupbyNodeBuildInfo buildInfo = distinctNodeBuildInfos.get(groupbyMapKey); if (buildInfo == null) { GroupbyNode distinctGroupbyNode = new GroupbyNode(context.getPlan().getLogicalPlan().newPID()); buildInfo = new DistinctGroupbyNodeBuildInfo(distinctGroupbyNode); distinctNodeBuildInfos.put(groupbyMapKey, buildInfo); GroupbyNode otherGroupbyNode = new GroupbyNode(context.getPlan().getLogicalPlan().newPID()); DistinctGroupbyNode baseDistinctNode = new DistinctGroupbyNode(context.getPlan().getLogicalPlan().newPID()); baseDistinctNode.setTargets(groupbyNode.getTargets()); baseDistinctNode.setGroupingColumns(groupbyNode.getGroupingColumns());
IndexScanInfo indexScanInfo = (IndexScanInfo) optimalPath; plan.addHistory("AccessPathRewriter chooses index scan for " + scanNode.getTableName()); IndexScanNode indexScanNode = new IndexScanNode(plan.newPID(), scanNode, indexScanInfo.getKeySchema(), indexScanInfo.getPredicates(), indexScanInfo.getIndexPath()); if (stack.empty() || block.getRoot().equals(scanNode)) {
IndexScanInfo indexScanInfo = (IndexScanInfo) optimalPath; plan.addHistory("AccessPathRewriter chooses index scan for " + scanNode.getTableName()); IndexScanNode indexScanNode = new IndexScanNode(plan.newPID(), scanNode, indexScanInfo.getKeySchema(), indexScanInfo.getPredicates(), indexScanInfo.getIndexPath()); if (stack.empty() || block.getRoot().equals(scanNode)) {
GroupbyNode firstStageGroupby = new GroupbyNode(context.plan.getLogicalPlan().newPID()); firstStageGroupby.setGroupingColumns(TUtil.toArray(firstStageGroupingColumns, Column.class)); firstStageGroupby.setAggFunctions(firstStageAggFunctions); GroupbyNode secondPhaseGroupby = new GroupbyNode(context.plan.getLogicalPlan().newPID()); secondPhaseGroupby.setGroupingColumns(originalGroupingColumns); secondPhaseGroupby.setAggFunctions(secondPhaseEvalNodes);
GroupbyNode firstStageGroupby = new GroupbyNode(context.plan.getLogicalPlan().newPID()); firstStageGroupby.setGroupingColumns(TUtil.toArray(firstStageGroupingColumns, Column.class)); firstStageGroupby.setAggFunctions(TUtil.toArray(firstStageAggFunctions, AggregationFunctionCallEval.class)); GroupbyNode secondPhaseGroupby = new GroupbyNode(context.plan.getLogicalPlan().newPID()); secondPhaseGroupby.setGroupingColumns(originalGroupingColumns); secondPhaseGroupby.setAggFunctions(TUtil.toArray(secondPhaseEvalNodes, AggregationFunctionCallEval.class));
throw new TajoRuntimeException(new NotImplementedException("Not-in subquery")); JoinNode joinNode = new JoinNode(plan.newPID()); joinNode.init(joinType, baseRelation, subqueryEval.getSubQueryNode()); joinNode.setJoinQual(buildJoinCondition(leftEval, subqueryEval.getSubQueryNode()));
@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(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; }
throw new TajoRuntimeException(new NotImplementedException("Not-in subquery")); JoinNode joinNode = new JoinNode(plan.newPID()); joinNode.init(joinType, baseRelation, subqueryEval.getSubQueryNode()); joinNode.setJoinQual(buildJoinCondition(leftEval, subqueryEval.getSubQueryNode()));