/** * If the given {@link ChannelInstance} has a measured cardinality, then register this cardinality in the * {@link #crossPlatformExecutor} with the corresponding {@link Channel} and all its siblings. * * @param channelInstance the said {@link ChannelInstance} */ protected void registerMeasuredCardinality(ChannelInstance channelInstance) { // Check if a cardinality was measured in the first place. final OptionalLong optionalCardinality = channelInstance.getMeasuredCardinality(); if (!optionalCardinality.isPresent()) { if (channelInstance.getChannel().isMarkedForInstrumentation()) { this.logger.warn( "No cardinality available for {}, although it was requested.", channelInstance.getChannel() ); } return; } this.crossPlatformExecutor.addCardinalityMeasurement(channelInstance); }
/** * 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); } }