/** * 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); } }