@Override public LogicalNode visitFilter(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { visit(context, plan, block, node.getChild(), stack); ExprsVerifier.verify(context.state, node, node.getQual()); return node; }
public SelectionExec(TaskAttemptContext context, SelectionNode plan, PhysicalExec child) { super(context, plan.getInSchema(), plan.getOutSchema(), child); this.qual = plan.getQual(); }
private static SelectionNode convertFilter(OverridableConf context, EvalContext evalContext, Map<Integer, LogicalNode> nodeMap, PlanProto.LogicalNode protoNode) { PlanProto.FilterNode filterProto = protoNode.getFilter(); SelectionNode selection = new SelectionNode(protoNode.getNodeId()); selection.setInSchema(convertSchema(protoNode.getInSchema())); selection.setOutSchema(convertSchema(protoNode.getOutSchema())); selection.setChild(nodeMap.get(filterProto.getChildSeq())); selection.setQual(EvalNodeDeserializer.deserialize(context, evalContext, filterProto.getQual())); return selection; }
@Override public LogicalNode visitFilter(PlanShapeFixerContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { super.visitFilter(context, plan, block, node, stack); if (node.hasQual()) { node.setQual(sortQual(node.getQual())); } return null; }
List<InEval> inSubqueries = extractInSubquery(node.getQual()); stack.push(node); for (InEval eachIn : inSubqueries) { visit(context, plan, childBlock, childBlock.getRoot(), stack); visit(context, plan, block, node.getChild(), stack); stack.pop(); LogicalNode baseRelation = node.getChild(); for (InEval eachIn : inSubqueries) { joinNode.getRightChild().getOutSchema()); joinNode.setInSchema(inSchema); joinNode.setOutSchema(node.getOutSchema()); EvalNode[] originDnfs = AlgebraicUtil.toDisjunctiveNormalFormArray(node.getQual()); List<EvalNode> rewrittenDnfs = new ArrayList<>(); for (EvalNode eachDnf : originDnfs) { node.setQual(AlgebraicUtil.createSingletonExprFromDNF(rewrittenDnfs.toArray(new EvalNode[rewrittenDnfs.size()]))); node.setChild(baseRelation); } else { PlannerUtil.replaceNode(plan, block.getRoot(), node, baseRelation);
@Override public LogicalNode visitFilter(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode selNode, Stack<LogicalNode> stack) throws TajoException { context.pushingDownFilters.addAll(new HashSet<>(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(selNode.getQual())))); visit(context, plan, block, selNode.getChild(), stack); stack.pop(); if (node instanceof UnaryNode) { UnaryNode unary = (UnaryNode) node; unary.setChild(selNode.getChild()); } else { throw new TajoInternalError("The node must be an unary node"); selNode.setQual(AlgebraicUtil.createSingletonExprFromCNF(matched.toArray(new EvalNode[matched.size()]))); context.pushingDownFilters.removeAll(matched);
public LogicalNode visitFilter(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { Context newContext = new Context(context); String referenceName = newContext.targetListMgr.add(node.getQual()); newContext.addNecessaryReferences(node.getQual()); LogicalNode child = super.visitFilter(newContext, plan, block, node, stack); node.setInSchema(child.getOutSchema()); node.setOutSchema(child.getOutSchema()); Target target = context.targetListMgr.getTarget(referenceName); if (newContext.targetListMgr.isEvaluated(referenceName)) { node.setQual(new FieldEval(target.getNamedColumn())); } else { node.setQual(target.getEvalTree()); newContext.targetListMgr.markAsEvaluated(target); } return node; }
@Override public PlanString getPlanString() { PlanString planStr = new PlanString(this); planStr.addExplan("Search Cond: " + getQual()); return planStr; }
@Override public RESULT visitFilter(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = visit(context, plan, block, node.getChild(), stack); stack.pop(); return result; }
SelectionNode topParentSelect = (SelectionNode) topParent; Set<EvalNode> filters = new HashSet<>(); filters.addAll(new HashSet<>(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(topParentSelect.getQual())))); filters.addAll(remainingQuals); topParentSelect.setQual(AlgebraicUtil.createSingletonExprFromCNF( filters.toArray(new EvalNode[filters.size()]))); return newJoinNode; } else { SelectionNode newSelection = plan.createNode(SelectionNode.class); newSelection.setQual(AlgebraicUtil.createSingletonExprFromCNF( remainingQuals.toArray(new EvalNode[remainingQuals.size()]))); newSelection.setChild(newJoinNode); return newSelection;
@Override public LogicalNode visitFilter(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { LogicalNode child = super.visitFilter(context, plan, block, node, stack); ExecutionBlock execBlock = context.execBlockMap.remove(child.getPID()); node.setChild(execBlock.getPlan()); node.setInSchema(execBlock.getPlan().getOutSchema()); execBlock.setPlan(node); context.execBlockMap.put(node.getPID(), execBlock); return node; }
@Override public LogicalNode visitFilter(ProcessorContext ctx, Stack<Expr> stack, Selection expr) throws TajoException { Set<ColumnReferenceExpr> columnSet = ExprFinder.finds(expr.getQual(), OpType.Column); for (ColumnReferenceExpr col : columnSet) { if (!ctx.aliasSet.contains(col.getName())) { NameRefInSelectListNormalizer.normalize(ctx.planContext, col); TUtil.putToNestedList(ctx.projectColumns, col.getQualifier(), col); } } super.visitFilter(ctx, stack, expr); SelectionNode node = getNodeFromExpr(ctx.planContext.getPlan(), expr); LogicalNode child = getNonRelationListExpr(ctx.planContext.getPlan(), expr.getChild()); node.setInSchema(child.getOutSchema()); node.setOutSchema(node.getInSchema()); return node; }
public LogicalNode visitFilter(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, Selection expr) throws TajoException { stack.push(expr); // Since filter push down will be done later, it is guaranteed that in-subqueries are found at only selection. for (Expr eachQual : PlannerUtil.extractInSubquery(expr.getQual())) { InPredicate inPredicate = (InPredicate) eachQual; stack.push(inPredicate); visit(ctx, stack, inPredicate.getRight()); stack.pop(); } LogicalNode child = visit(ctx, stack, expr.getChild()); stack.pop(); SelectionNode selectionNode = ctx.getPlan().createNode(SelectionNode.class); selectionNode.setInSchema(child.getOutSchema()); selectionNode.setOutSchema(child.getOutSchema()); return selectionNode; }
@Override public LogicalNode visitFilter(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { super.visitFilter(context, plan, block, node, stack); compileSelectableNode(context, node.getInSchema(), node); return node; }
List<InEval> inSubqueries = extractInSubquery(node.getQual()); stack.push(node); for (InEval eachIn : inSubqueries) { visit(context, plan, childBlock, childBlock.getRoot(), stack); visit(context, plan, block, node.getChild(), stack); stack.pop(); LogicalNode baseRelation = node.getChild(); for (InEval eachIn : inSubqueries) { joinNode.getRightChild().getOutSchema()); joinNode.setInSchema(inSchema); joinNode.setOutSchema(node.getOutSchema()); EvalNode[] originDnfs = AlgebraicUtil.toDisjunctiveNormalFormArray(node.getQual()); List<EvalNode> rewrittenDnfs = TUtil.newList(); for (EvalNode eachDnf : originDnfs) { node.setQual(AlgebraicUtil.createSingletonExprFromDNF(rewrittenDnfs.toArray(new EvalNode[rewrittenDnfs.size()]))); node.setChild(baseRelation); } else { PlannerUtil.replaceNode(plan, block.getRoot(), node, baseRelation);
@Override public LogicalNode visitFilter(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode selNode, Stack<LogicalNode> stack) throws TajoException { context.pushingDownFilters.addAll(new HashSet<>(Arrays.asList(AlgebraicUtil.toConjunctiveNormalFormArray(selNode.getQual())))); visit(context, plan, block, selNode.getChild(), stack); stack.pop(); if (node instanceof UnaryNode) { UnaryNode unary = (UnaryNode) node; unary.setChild(selNode.getChild()); } else { throw new TajoInternalError("The node must be an unary node"); selNode.setQual(AlgebraicUtil.createSingletonExprFromCNF(matched.toArray(new EvalNode[matched.size()]))); context.pushingDownFilters.removeAll(matched);
public LogicalNode visitFilter(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { Context newContext = new Context(context); String referenceName = newContext.targetListMgr.add(node.getQual()); newContext.addNecessaryReferences(node.getQual()); LogicalNode child = super.visitFilter(newContext, plan, block, node, stack); node.setInSchema(child.getOutSchema()); node.setOutSchema(child.getOutSchema()); Target target = context.targetListMgr.getTarget(referenceName); if (newContext.targetListMgr.isEvaluated(referenceName)) { node.setQual(new FieldEval(target.getNamedColumn())); } else { node.setQual(target.getEvalTree()); newContext.targetListMgr.markAsEvaluated(target); } return node; }
@Override public PlanString getPlanString() { PlanString planStr = new PlanString(this); planStr.addExplan("Search Cond: " + getQual()); return planStr; }
@Override public RESULT visitFilter(CONTEXT context, LogicalPlan plan, LogicalPlan.QueryBlock block, SelectionNode node, Stack<LogicalNode> stack) throws TajoException { stack.push(node); RESULT result = visit(context, plan, block, node.getChild(), stack); stack.pop(); return result; }