/** * Creates a {@link Stream} of this instance and its siblings. The sibling relationship must not be altered * while processing the {@link Stream}. * * @return the {@link Stream} */ public Stream<Channel> withSiblings() { return this.withSiblings(false); }
public boolean isMarkedForInstrumentation() { return this.withSiblings(false).anyMatch(sibling -> sibling.isMarkedForInstrumentation); }
public void markForInstrumentation() { this.withSiblings(false).forEach(channel -> { channel.isMarkedForInstrumentation = true; LoggerFactory.getLogger(this.getClass()).debug("Marked {} for instrumentation.", channel); }); }
/** * @return all {@link InputSlot}s and {@link OutputSlot}s that are represented by this instance and its * {@link #siblings} */ public Collection<Slot<?>> getCorrespondingSlots() { return this.withSiblings(false) .map(Channel::getCorrespondingSlotsLocal) .reduce(Stream.empty(), Stream::concat) .collect(Collectors.toList()); }
/** * Acquaints the given instance with this instance and all existing {@link #siblings}. */ public void addSibling(Channel sibling) { if (sibling == this) return; this.withSiblings(true).forEach(olderSibling -> olderSibling.relateTo(sibling)); }
/** * @return the {@link DataSetType} of this instance (requires a producer) * @see #setProducer(ExecutionTask) */ public DataSetType<?> getDataSetType() { return this.withSiblings(false) .filter(sibling -> sibling.getProducerSlot() != null) .findAny() .orElseThrow(() -> new IllegalStateException(String.format("No DataSetType for %s.", this))) .getProducerSlot().getType(); }
public CardinalityEstimate getCardinalityEstimate(OptimizationContext optimizationContext) { return this.withSiblings(false) .map(sibling -> { final OutputSlot<?> output = sibling.getProducerSlot(); if (output == null) return null; final OptimizationContext.OperatorContext operatorCtx = optimizationContext.getOperatorContext(output.getOwner()); if (operatorCtx == null) return null; return operatorCtx.getOutputCardinality(output.getIndex()); }).filter(Objects::nonNull) .findAny() .orElseThrow(() -> new IllegalStateException(String.format( "No CardinalityEstimate for %s (available: %s).", this, optimizationContext.getLocalOperatorContexts() ))); }