@Override public void contributeMicroOperator(ILogicalOperator op, IPushRuntimeFactory runtime, RecordDescriptor recDesc, AlgebricksPartitionConstraint pc) { microOps.put(op, new Pair<>(runtime, recDesc)); revMicroOpMap.put(runtime, op); if (pc != null) { pcForMicroOps.put(op, pc); } AbstractLogicalOperator logicalOp = (AbstractLogicalOperator) op; if (logicalOp.getExecutionMode() == ExecutionMode.UNPARTITIONED && pc == null) { AlgebricksPartitionConstraint apc = countOneLocation; pcForMicroOps.put(logicalOp, apc); } }
@Override public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) { AbstractLogicalOperator limitOp = (AbstractLogicalOperator) op; if (limitOp.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.UNPARTITIONED) { StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1]; pv[0] = new StructuralPropertiesVector(IPartitioningProperty.UNPARTITIONED, null); return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION); } else { return emptyUnaryRequirements(); } }
protected void contributeOpDesc(IHyracksJobBuilder builder, AbstractLogicalOperator op, IOperatorDescriptor opDesc) { if (op.getExecutionMode() == ExecutionMode.UNPARTITIONED) { AlgebricksPartitionConstraint apc = new AlgebricksCountPartitionConstraint(1); builder.contributeAlgebricksPartitionConstraint(opDesc, apc); } builder.contributeHyracksOperator(op, opDesc); }
private void appendPhysicalOperatorInfo(AbstractLogicalOperator op, boolean show) { IPhysicalOperator physicalOp = op.getPhysicalOperator(); stringBuilder.append("\\n").append(physicalOp == null ? "null" : physicalOp.toString().trim()); stringBuilder.append(", Exec: ").append(op.getExecutionMode()); if (show) { IPhysicalPropertiesVector properties = physicalOp == null ? null : physicalOp.getDeliveredProperties();
@Override public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) { StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1]; List<ILocalStructuralProperty> localProps = new ArrayList<>(); List<OrderColumn> orderColumns = new ArrayList<>(); for (LogicalVariable column : columnList) { orderColumns.add(new OrderColumn(column, OrderOperator.IOrder.OrderKind.ASC)); } localProps.add(new LocalOrderProperty(orderColumns)); IPartitioningProperty pp = null; AbstractLogicalOperator aop = (AbstractLogicalOperator) op; if (aop.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) { pp = new UnorderedPartitionedProperty(new ListSet<>(columnList), context.getComputationNodeDomain()); } pv[0] = new StructuralPropertiesVector(pp, localProps); return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION); }
@Override public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) { AbstractLogicalOperator limitOp = (AbstractLogicalOperator) op; ILogicalOperator op2 = op.getInputs().get(0).getValue(); if (limitOp.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.UNPARTITIONED) { //partitioning property: unpartitioned; local property: whatever from the child deliveredProperties = new StructuralPropertiesVector(IPartitioningProperty.UNPARTITIONED, op2.getDeliveredPhysicalProperties().getLocalProperties()); } else { deliveredProperties = op2.getDeliveredPhysicalProperties().clone(); } }
@Override public void printOperator(AbstractLogicalOperator op, int indent) throws AlgebricksException { final AlgebricksAppendable out = this.get(); op.accept(this, indent); IPhysicalOperator pOp = op.getPhysicalOperator(); if (pOp != null) { out.append("\n"); pad(out, indent); appendln(out, "-- " + pOp.toString() + " |" + op.getExecutionMode() + "|"); } else { appendln(out, " -- |" + op.getExecutionMode() + "|"); } for (Mutable<ILogicalOperator> i : op.getInputs()) { printOperator((AbstractLogicalOperator) i.getValue(), indent + 2); } }
private static boolean pushAllProjectionsOnTopOf(Collection<LogicalVariable> toPush, Mutable<ILogicalOperator> opRef, IOptimizationContext context, ILogicalOperator initialOp) throws AlgebricksException { if (toPush.isEmpty()) { return false; } AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (context.checkAndAddToAlreadyCompared(initialOp, op)) { return false; } if (op.getOperatorTag() == LogicalOperatorTag.PROJECT) { return false; } ProjectOperator pi2 = new ProjectOperator(new ArrayList<LogicalVariable>(toPush)); pi2.setSourceLocation(op.getSourceLocation()); pi2.getInputs().add(new MutableObject<ILogicalOperator>(op)); opRef.setValue(pi2); pi2.setExecutionMode(op.getExecutionMode()); context.computeAndSetTypeEnvironmentForOperator(pi2); return true; }
@Override public void computeDeliveredProperties(ILogicalOperator iop, IOptimizationContext context) { if (partitioningType != JoinPartitioningType.BROADCAST) { throw new NotImplementedException(partitioningType + " nested loop joins are not implemented."); } IPartitioningProperty pp; AbstractLogicalOperator op = (AbstractLogicalOperator) iop; if (op.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) { AbstractLogicalOperator op2 = (AbstractLogicalOperator) op.getInputs().get(1).getValue(); IPhysicalPropertiesVector pv1 = op2.getPhysicalOperator().getDeliveredProperties(); if (pv1 == null) { pp = null; } else { pp = pv1.getPartitioningProperty(); } } else { pp = IPartitioningProperty.UNPARTITIONED; } // Nested loop join cannot maintain the local structure property for the probe side // because of the I/O optimization for the build branch. this.deliveredProperties = new StructuralPropertiesVector(pp, null); }
@Override public void computeDeliveredProperties(ILogicalOperator iop, IOptimizationContext context) throws AlgebricksException { IPartitioningProperty pp; AbstractLogicalOperator op = (AbstractLogicalOperator) iop; if (op.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) { AbstractLogicalOperator op0 = (AbstractLogicalOperator) op.getInputs().get(0).getValue(); IPhysicalPropertiesVector pv0 = op0.getPhysicalOperator().getDeliveredProperties(); AbstractLogicalOperator op1 = (AbstractLogicalOperator) op.getInputs().get(1).getValue(); IPhysicalPropertiesVector pv1 = op1.getPhysicalOperator().getDeliveredProperties(); if (pv0 == null || pv1 == null) { pp = null; } else { pp = pv0.getPartitioningProperty(); } } else { pp = IPartitioningProperty.UNPARTITIONED; } this.deliveredProperties = new StructuralPropertiesVector(pp, deliveredLocalProperties(iop, context)); }
private final static void insertOneToOneExchange(Mutable<ILogicalOperator> i, IOptimizationContext context) throws AlgebricksException { ExchangeOperator e = new ExchangeOperator(); e.setPhysicalOperator(new OneToOneExchangePOperator()); ILogicalOperator inOp = i.getValue(); e.getInputs().add(new MutableObject<ILogicalOperator>(inOp)); i.setValue(e); // e.recomputeSchema(); OperatorPropertiesUtil.computeSchemaAndPropertiesRecIfNull(e, context); ExecutionMode em = ((AbstractLogicalOperator) inOp).getExecutionMode(); e.setExecutionMode(em); e.computeDeliveredPhysicalProperties(context); context.computeAndSetTypeEnvironmentForOperator(e); }
@Override public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) { AbstractLogicalOperator aop = (AbstractLogicalOperator) op; if (aop.getExecutionMode() == ExecutionMode.PARTITIONED) { StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1]; pv[0] = new StructuralPropertiesVector(new UnorderedPartitionedProperty( new ListSet<LogicalVariable>(columnSet), context.getComputationNodeDomain()), null); return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION); } else { return emptyUnaryRequirements(); } }
if (aop.getExecutionMode() == ExecutionMode.PARTITIONED) { pp = new UnorderedPartitionedProperty(new ListSet<>(columnList), context.getComputationNodeDomain());
return false; if (subTreeOp.getExecutionMode() != ExecutionMode.UNPARTITIONED) {
public static boolean setOperatorMode(AbstractLogicalOperator op) { AbstractLogicalOperator.ExecutionMode oldMode = op.getExecutionMode(); switch (op.getOperatorTag()) { case DATASOURCESCAN: { AbstractLogicalOperator prevOp = (AbstractLogicalOperator) nts.getDataSourceReference().getValue().getInputs().get(0).getValue(); if (prevOp.getExecutionMode() != AbstractLogicalOperator.ExecutionMode.UNPARTITIONED) { nts.setExecutionMode(AbstractLogicalOperator.ExecutionMode.LOCAL); boolean exit = false; AbstractLogicalOperator inputOp = (AbstractLogicalOperator) i.getValue(); switch (inputOp.getExecutionMode()) { case PARTITIONED: { if (forceUnpartitioned) { return oldMode != op.getExecutionMode();
public static void printPhysicalOperator(AbstractLogicalOperator op, int indent, AlgebricksAppendable out) throws AlgebricksException { IPhysicalOperator pOp = op.getPhysicalOperator(); pad(out, indent); appendln(out, "-- " + pOp.toString() + " |" + op.getExecutionMode() + "|"); if (op.hasNestedPlans()) { AbstractOperatorWithNestedPlans opNest = (AbstractOperatorWithNestedPlans) op; for (ILogicalPlan p : opNest.getNestedPlans()) { pad(out, indent + 8); appendln(out, "{"); printPhysicalOps(p, out, indent + 10); pad(out, indent + 8); appendln(out, "}"); } } for (Mutable<ILogicalOperator> i : op.getInputs()) { printPhysicalOperator((AbstractLogicalOperator) i.getValue(), indent + 2, out); } }
private boolean assignCommonExpression(ExprEquivalenceClass exprEqClass, ILogicalExpression expr) throws AlgebricksException { SourceLocation sourceLoc = expr.getSourceLocation(); AbstractLogicalOperator firstOp = (AbstractLogicalOperator) exprEqClass.getFirstOperator(); Mutable<ILogicalExpression> firstExprRef = exprEqClass.getFirstExpression(); // We don't consider to eliminate common exprs in join operators by doing a cartesian production // and pulling the condition in to a select. This will negatively impact the performance. if (firstOp.getInputs().size() > 1) { // Bail for any non-join operator with multiple inputs. return false; } LogicalVariable newVar = context.newVar(); AssignOperator newAssign = new AssignOperator(newVar, new MutableObject<ILogicalExpression>(firstExprRef.getValue().cloneExpression())); newAssign.setSourceLocation(sourceLoc); // Place assign below firstOp. newAssign.getInputs().add(new MutableObject<ILogicalOperator>(firstOp.getInputs().get(0).getValue())); newAssign.setExecutionMode(firstOp.getExecutionMode()); firstOp.getInputs().get(0).setValue(newAssign); // Replace original expr with variable reference, and set var in expression equivalence class. VariableReferenceExpression newVarRef = new VariableReferenceExpression(newVar); newVarRef.setSourceLocation(sourceLoc); firstExprRef.setValue(newVarRef); exprEqClass.setVariable(newVar); context.computeAndSetTypeEnvironmentForOperator(newAssign); context.computeAndSetTypeEnvironmentForOperator(firstOp); return true; }
AssignOperator newAssign = new AssignOperator(newVar, new MutableObject<ILogicalExpression>(exprRef .getValue().cloneExpression())); newAssign.setExecutionMode(joinOp.getExecutionMode());
append(out, "\"execution-mode\": \"" + op.getExecutionMode() + '"'); if (!op.getInputs().isEmpty()) { appendln(out, ",");
new MutableObject<ILogicalExpression>(exprRef.getValue().cloneExpression())); newAssign.setSourceLocation(exprRefSourceLoc); newAssign.setExecutionMode(joinOp.getExecutionMode());