public void add(ExecutionStage executionStage) { if (this.allStages.add(executionStage)) { if (this.headStageCache == null && this.checkForLoopHead(executionStage)) { this.headStageCache = executionStage; } } }
/** * Determine if this instance is the loop head of its {@link ExecutionStageLoop}. * * @return {@code true} if the above condition is fulfilled or there is no {@link ExecutionStageLoop} */ public boolean isLoopHead() { return this.executionStageLoop != null && this.executionStageLoop.getLoopHead() == this; }
/** * Notify the {@link #executionStageLoop} that there is a new {@link ExecutionTask} in this instance, which might * comprise the {@link LoopHeadOperator}. * * @param task */ private void updateLoop(ExecutionTask task) { if (this.executionStageLoop != null) { this.executionStageLoop.update(task); } }
/** * Find the initial {@link OptimizationContext} for a {@link StageActivator}. * * @param stage the {@link ExecutionStage} whose {@link OptimizationContext} is to be determined * @return the {@link OptimizationContext} */ private OptimizationContext determineInitialOptimizationContext(ExecutionStage stage, OptimizationContext rootOptimizationContext) { if (stage.getLoop() == null) return rootOptimizationContext; // TODO: Assumes non-nested loops. return rootOptimizationContext.getNestedLoopContext(stage.getLoop().getLoopSubplan()).getInitialIterationContext(); }
/** * Create a new instance and register it with the given {@link PlatformExecution}. */ ExecutionStage(PlatformExecution platformExecution, ExecutionStageLoop executionStageLoop, int sequenceNumber) { this.platformExecution = platformExecution; this.sequenceNumber = sequenceNumber; this.executionStageLoop = executionStageLoop; if (this.executionStageLoop != null) { this.executionStageLoop.add(this); } this.platformExecution.addStage(this); }
/** * Inspect whether {@link ExecutionTask} is the {@link LoopHeadOperator} of the {@link #loopSubplan}. If so, * promote its {@link ExecutionStage} as the loop head. * * @param task to be checked */ public void update(ExecutionTask task) { if (this.headStageCache == null && this.isLoopHead(task)) { this.headStageCache = task.getStage(); } }
final LoopSubplan loopSubplan = successorStage.getLoop().getLoopSubplan(); return prevOptimizationContext .getRootParent()
/** * Tells whether this instance is in a {@link ExecutionStageLoop} that has finished iterating. * * @return whether this instance is in a finished {@link ExecutionStageLoop} * @see #isLoopHead() */ public boolean isInFinishedLoop() { if (this.executionStageLoop == null) { return false; } final LoopHeadOperator loopHeadOperator = (LoopHeadOperator) this.executionStageLoop.getLoopHead().getLoopHeadTask().getOperator(); return loopHeadOperator.getState() == LoopHeadOperator.State.FINISHED; }