@Override public boolean permitsExecutionOf(ExecutionStage stage, ExecutionState state, OptimizationContext optimizationContext) { for (Channel channel : stage.getInboundChannels()) { final CardinalityEstimate cardinalityEstimate = this.getCardinalityEstimate(channel, optimizationContext); if (cardinalityEstimate == null) { // TODO: We might need to look inside of LoopContexts. this.logger.warn("Could not find a cardinality estimate for {}.", channel); // Be conservative here. return false; } else { if (!this.approves(cardinalityEstimate)) { return false; } } } return true; }
/** * Whether the given {@link CardinalityEstimate} does not require a breakpoint. * * @param cardinalityEstimate the {@link CardinalityEstimate} * @return whether no breakpoint is needed */ public boolean approves(CardinalityEstimate cardinalityEstimate) { return cardinalityEstimate.getCorrectnessProbability() >= this.minConfidence && this.calculateSpread(cardinalityEstimate) <= this.maxSpread; }
/** * Whether a {@link Breakpoint} is requested for the given {@link OutputSlot}. * * @param output the {@link OutputSlot} * @param operatorContext the {@link OptimizationContext.OperatorContext} for the {@link OutputSlot} owner * @return whether a {@link Breakpoint} is requested */ public boolean isRequestBreakpointFor(OutputSlot<?> output, OptimizationContext.OperatorContext operatorContext) { return this.isProactiveReoptimization && output.getOwner().getInnermostLoop() == null && this.cardinalityBreakpoint != null && !this.cardinalityBreakpoint.approves(operatorContext.getOutputCardinality(output.getIndex()) ); }
this.cardinalityBreakpoint = new CardinalityBreakpoint(this.configuration); this.isProactiveReoptimization = this.configuration.getBooleanProperty("rheem.core.optimizer.reoptimize.proactive", false);