/** * Injects the cardinalities of a current {@link ExecutionState} into its associated {@link RheemPlan} * (or its {@link OptimizationContext}, respectively) and then reperforms the cardinality estimation. * * @return whether any cardinalities have been injected */ public boolean pushCardinalityUpdates(ExecutionState executionState, PlanImplementation planImplementation) { boolean isInjected = this.injectMeasuredCardinalities(executionState); if (isInjected) this.pushCardinalities(planImplementation); return isInjected; }
/** * Go over the given {@link RheemPlan} and update the cardinalities of data being passed between its * {@link Operator}s using the given {@link ExecutionState}. * * @return whether any cardinalities have been updated */ private boolean reestimateCardinalities(ExecutionState executionState) { return this.cardinalityEstimatorManager.pushCardinalityUpdates(executionState, this.planImplementation); }
/** * Traverse the {@link RheemPlan}, thereby updating {@link CardinalityEstimate}s. Also update conversion * {@link Operator} cardinalities as provided by the {@link PlanImplementation}. * * @param planImplementation that has conversion {@link Operator}s * @return whether any {@link CardinalityEstimate}s have been updated */ public boolean pushCardinalities(PlanImplementation planImplementation) { boolean isUpdated = this.getPlanTraversal().traverse(this.optimizationContext, this.configuration); planImplementation.getLoopImplementations().keySet().forEach( loop -> this.optimizationContext.getNestedLoopContext(loop).getAggregateContext().updateOperatorContexts() ); this.updateConversionOperatorCardinalities(planImplementation, this.optimizationContext, 0); this.optimizationContext.clearMarks(); return isUpdated; }
/** * Go over the given {@link RheemPlan} and estimate the cardinalities of data being passed between its * {@link Operator}s and the execution profile and time of {@link ExecutionOperator}s. */ private void estimateKeyFigures() { this.logger.info("Estimating cardinalities and execution load..."); this.optimizationRound.start("Cardinality&Load Estimation"); if (this.cardinalityEstimatorManager == null) { this.optimizationRound.start("Cardinality&Load Estimation", "Create OptimizationContext"); this.optimizationContext = DefaultOptimizationContext.createFrom(this); this.optimizationRound.stop("Cardinality&Load Estimation", "Create OptimizationContext"); this.optimizationRound.start("Cardinality&Load Estimation", "Create CardinalityEstimationManager"); this.cardinalityEstimatorManager = new CardinalityEstimatorManager( this.rheemPlan, this.optimizationContext, this.configuration); this.optimizationRound.stop("Cardinality&Load Estimation", "Create CardinalityEstimationManager"); } this.optimizationRound.start("Cardinality&Load Estimation", "Push Estimation"); this.cardinalityEstimatorManager.pushCardinalities(); this.optimizationRound.stop("Cardinality&Load Estimation", "Push Estimation"); this.optimizationRound.stop("Cardinality&Load Estimation"); }
/** * Traverse the {@link RheemPlan}, thereby updating {@link CardinalityEstimate}s. * * @return whether any {@link CardinalityEstimate}s have been updated */ public boolean pushCardinalities() { boolean isUpdated = this.getPlanTraversal().traverse(this.optimizationContext, this.configuration); this.optimizationContext.clearMarks(); return isUpdated; }
/** * Injects the measured cardinality of a {@link ChannelInstance}. */ private void injectMeasuredCardinality(ChannelInstance channelInstance) { assert channelInstance.wasProduced(); assert channelInstance.isMarkedForInstrumentation(); // Obtain cardinality measurement. final long cardinality = channelInstance.getMeasuredCardinality().getAsLong(); // Try to inject into the RheemPlan Operator output. final OutputSlot<?> rheemPlanOutput = OptimizationUtils.findRheemPlanOutputSlotFor(channelInstance.getChannel()); int outputIndex = rheemPlanOutput == null ? 0 : rheemPlanOutput.getIndex(); OptimizationContext optimizationContext = channelInstance.getProducerOperatorContext().getOptimizationContext(); final OptimizationContext.OperatorContext rheemPlanOperatorCtx = optimizationContext.getOperatorContext(rheemPlanOutput.getOwner()); if (rheemPlanOperatorCtx != null) { this.injectMeasuredCardinality(cardinality, rheemPlanOperatorCtx, outputIndex); } else { this.logger.warn("Could not inject cardinality measurement {} for {}.", cardinality, rheemPlanOutput); } }
this.updateConversionOperatorCardinalities( loopImplementation.getSingleIterationImplementation().getBodyImplementation(), iterationContext,