public ChannelLineageNode(final ChannelInstance channelInstance) { assert !channelInstance.wasProduced(); this.channelInstance = channelInstance; this.channelInstance.noteObtainedReference(); }
/** * Select the produced {@link ChannelInstance}s that are marked for instrumentation and register them if they * contain a measured cardinality. * * @param producedChannelInstances the {@link ChannelInstance}s */ protected void registerMeasuredCardinalities(Collection<ChannelInstance> producedChannelInstances) { for (ChannelInstance producedChannelInstance : producedChannelInstances) { if (!producedChannelInstance.wasProduced()) { this.logger.error("Expected {} to be produced, but is not flagged as such.", producedChannelInstance); continue; } if (producedChannelInstance.isMarkedForInstrumentation()) { this.registerMeasuredCardinality(producedChannelInstance); } } }
@Override protected void markAsExecuted() { super.markAsExecuted(); assert !this.channelInstance.wasProduced(); this.channelInstance.markProduced(); this.channelInstance.noteDiscardedReference(false); }
/** * 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); } }