public static ILogicalOperator eliminateSingleSubplanOverEts(SubplanOperator subplan) { if (subplan.getNestedPlans().size() > 1) { // not a single subplan List<Mutable<ILogicalOperator>> subInpList = subplan.getInputs(); subInpList.clear(); subInpList.add(new MutableObject<ILogicalOperator>(new EmptyTupleSourceOperator())); return subplan; } ILogicalPlan plan = subplan.getNestedPlans().get(0); if (plan.getRoots().size() > 1) { // not a single subplan List<Mutable<ILogicalOperator>> subInpList = subplan.getInputs(); subInpList.clear(); subInpList.add(new MutableObject<ILogicalOperator>(new EmptyTupleSourceOperator())); return subplan; } return plan.getRoots().get(0).getValue(); }
@Override public ILogicalOperator visitSubplanOperator(SubplanOperator op, Void arg) throws AlgebricksException { ArrayList<ILogicalPlan> newSubplans = new ArrayList<>(); SubplanOperator subplanOp = new SubplanOperator(newSubplans); for (ILogicalPlan plan : op.getNestedPlans()) { newSubplans.add(OperatorManipulationUtil.deepCopy(plan, subplanOp)); } return subplanOp; }
TranslationContext popContext() { SubplanOperator sOp = (SubplanOperator) parent.op; sOp.setRootOp(mutable(op)); return parent; }
TranslationContext pushContext() { SubplanOperator sOp = new SubplanOperator(); sOp.getInputs().add(mutable(op)); op = sOp; NestedTupleSourceOperator ntsOp = new NestedTupleSourceOperator(mutable(sOp)); TranslationContext childCtx = new TranslationContext(this, ntsOp); return childCtx; }
private Pair<Boolean, LinkedHashMap<LogicalVariable, LogicalVariable>> applySpecialFlattening( Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { SubplanOperator subplanOp = (SubplanOperator) opRef.getValue(); SourceLocation sourceLoc = subplanOp.getSourceLocation(); Mutable<ILogicalOperator> inputOpRef = subplanOp.getInputs().get(0); LinkedHashMap<LogicalVariable, LogicalVariable> replacedVarMap = new LinkedHashMap<>(); rewriteSubplanOperator(subplanOp.getNestedPlans().get(0).getRoots().get(0), context); GroupByOperator groupbyOp = new GroupByOperator(groupByList, groupByDecorList, subplanOp.getNestedPlans()); groupbyOp.setSourceLocation(sourceLoc);
private static void ntsToEtsInSubplan(SubplanOperator s, IOptimizationContext context) throws AlgebricksException { for (ILogicalPlan p : s.getNestedPlans()) { for (Mutable<ILogicalOperator> r : p.getRoots()) { OperatorManipulationUtil.ntsToEts(r, context); } } }
context.enterSubplan(); SourceLocation sourceLoc = inputOp.getSourceLocation(); SubplanOperator subplanOp = new SubplanOperator(); subplanOp.getInputs().add(new MutableObject<>(inputOp)); subplanOp.setSourceLocation(sourceLoc); NestedTupleSourceOperator ntsOp = new NestedTupleSourceOperator(new MutableObject<>(subplanOp)); ntsOp.setSourceLocation(sourceLoc); aggOp.setSourceLocation(branchExpression.getSourceLocation()); ILogicalPlan planForBranch = new ALogicalPlanImpl(new MutableObject<>(aggOp)); subplanOp.getNestedPlans().add(planForBranch); context.exitSubplan(); return new Pair<>(subplanOp, branchVar);
SubplanOperator subplanOperator = new SubplanOperator(); subplanOperator.setSourceLocation(sourceLoc); subplanOperator.setRootOp(new MutableObject<>(aggregateOperator)); subplanOperator.getInputs().add(op.getInputs().get(0)); op.getInputs().set(0, new MutableObject<>(subplanOperator)); VariableReferenceExpression aggVarRef = new VariableReferenceExpression(aggVar);
SubplanOperator subplanOperator = new SubplanOperator(); subplanOperator.getInputs().add(assign.getInputs().get(0)); subplanOperator.setRootOp(nextOperatorRef);
private void elimSubplanOverEts(Mutable<ILogicalOperator> opRef, IOptimizationContext ctx) throws AlgebricksException { SubplanOperator subplan = (SubplanOperator) opRef.getValue(); SourceLocation sourceLoc = subplan.getSourceLocation(); for (ILogicalPlan p : subplan.getNestedPlans()) { for (Mutable<ILogicalOperator> r : p.getRoots()) { OperatorManipulationUtil.ntsToEts(r, ctx); LinkedList<Mutable<ILogicalOperator>> allRoots = subplan.allRootsInReverseOrder(); if (allRoots.size() == 1) { opRef.setValue(allRoots.get(0).getValue());
@Override public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException { SubplanOperator subplan = (SubplanOperator) op; if (subplan.getNestedPlans().size() != 1) { throw new NotImplementedException("Subplan currently works only for one nested plan with one root."); } List<List<AlgebricksPipeline>> subplans = compileSubplansImpl(inputSchemas[0], subplan, opSchema, context); assert subplans.size() == 1; List<AlgebricksPipeline> np = subplans.get(0); RecordDescriptor inputRecordDesc = JobGenHelper.mkRecordDescriptor( context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas[0], context); IMissingWriterFactory[] missingWriterFactories = new IMissingWriterFactory[np.get(0).getOutputWidth()]; for (int i = 0; i < missingWriterFactories.length; i++) { missingWriterFactories[i] = context.getMissingWriterFactory(); } RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context); SubplanRuntimeFactory runtime = new SubplanRuntimeFactory(np, missingWriterFactories, inputRecordDesc, recDesc, null); runtime.setSourceLocation(subplan.getSourceLocation()); builder.contributeMicroOperator(subplan, runtime, recDesc); ILogicalOperator src = op.getInputs().get(0).getValue(); builder.contributeGraphEdge(src, 0, op, 0); }
@Override public Long visitSubplanOperator(SubplanOperator op, Void arg) throws AlgebricksException { return op.getInputs().get(0).getValue().accept(this, arg); }
@Override public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException { return createNestedPlansPropagatingTypeEnvironment(ctx, true); } }
return new Pair<>(false, new LinkedHashMap<>()); SourceLocation sourceLoc = subplanOp.getSourceLocation(); Mutable<ILogicalOperator> inputOpRef = subplanOp.getInputs().get(0); ILogicalOperator inputOpBackup = inputOpRef.getValue(); SubplanFlatteningUtil.findLowestAggregate(subplanOp.getNestedPlans().get(0).getRoots().get(0)); Mutable<ILogicalOperator> rightInputOpRef = lowestAggregateRefInSubplan.getValue().getInputs().get(0); ILogicalOperator rightInputOp = rightInputOpRef.getValue(); Mutable<ILogicalOperator> aggOpRef = subplanOp.getNestedPlans().get(0).getRoots().get(0);
private static void cleanupJoins(SubplanOperator s) { for (ILogicalPlan p : s.getNestedPlans()) { for (Mutable<ILogicalOperator> r : p.getRoots()) { cleanupJoins(r); } } }
} else { SubplanOperator subplanOp = new SubplanOperator(); subplanOp.getInputs().add(leftInputRef); subplanOp.setSourceLocation(sourceLoc); NestedTupleSourceOperator ntsOp = new NestedTupleSourceOperator(new MutableObject<>(subplanOp)); ntsOp.setSourceLocation(sourceLoc); subplanOp.getNestedPlans().add(subplan);
return new Pair<>(varRef, top2); } else { SubplanOperator s = new SubplanOperator(); s.getInputs().add(topOpRef); s.setSourceLocation(sourceLoc); NestedTupleSourceOperator ntsOp = new NestedTupleSourceOperator(new MutableObject<>(s)); ntsOp.setSourceLocation(sourceLoc); srcRef.setValue(ntsOp); Mutable<ILogicalOperator> planRoot = new MutableObject<>(p.first); s.setRootOp(planRoot); VariableReferenceExpression varRef = new VariableReferenceExpression(p.second); varRef.setSourceLocation(sourceLoc);
SubplanOperator subplanOperator = new SubplanOperator(); subplanOperator.getInputs().add(assign.getInputs().get(0)); subplanOperator.setRootOp(nextOperatorRef);
resOp = rOp; } else { SubplanOperator s = new SubplanOperator(rOp); s.getInputs().add(flworPlan); resOp = s; baseOp.setValue(new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(s)));
Mutable<ILogicalOperator> opRef3 = subplan.getInputs().get(0); AbstractLogicalOperator op3 = (AbstractLogicalOperator) opRef3.getValue();