/** * @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(); }
/** * Collect the {@link OutputSlot} of the producer and the {@link InputSlot}s of the consumers that are implemented * by this instance. * * @return a {@link Stream} of said {@link Slot}s */ private Stream<Slot<?>> getCorrespondingSlotsLocal() { final Stream<? extends OutputSlot<?>> outputSlotStream = streamNullable(this.getProducerSlot()); final Stream<? extends InputSlot<?>> inputSlotStream = this.consumers.stream().flatMap(consumer -> streamNullable(consumer.getInputSlotFor(this))); return Stream.concat(inputSlotStream, outputSlotStream); }
@Override public String toString() { return String.format("%s[%s->%s]", this.getClass().getSimpleName(), this.getProducer() == null ? this.getProducerSlot() : this.getProducer(), this.getConsumers()); }
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() ))); }
Integer thisOutIndex = channel.getProducerSlot()==null ? 0 : channel.getProducerSlot().getIndex(); jsonConnectsTo.put(thisOutIndex.toString(), perOutputThatList);
/** * Try to extract the {@link CardinalityEstimate} for a {@link Channel} within an {@link OptimizationContext}. * * @param channel whose {@link CardinalityEstimate} is sought * @param optimizationContext provides {@link CardinalityEstimate}s * @return the {@link CardinalityEstimate} */ private CardinalityEstimate determineCardinality(Channel channel, OptimizationContext optimizationContext) { final ExecutionOperator sourceOperator = channel.getProducerOperator(); final OptimizationContext.OperatorContext sourceOpCtx = optimizationContext.getOperatorContext(sourceOperator); assert sourceOpCtx != null : String.format("No OperatorContext found for %s.", sourceOperator); final OutputSlot<?> producerSlot = channel.getProducerSlot(); if (producerSlot != null) { return sourceOpCtx.getOutputCardinality(producerSlot.getIndex()); } else if (sourceOperator.getNumInputs() == 1) { return sourceOpCtx.getInputCardinality(0); } throw new IllegalStateException(String.format("Could not determine cardinality of %s.", channel)); }
/** * Creates a new, hierarchical instance. Mimes the {@code original}'s properties except for the {@link #consumers}. * * @param original the original instance whose properties will be mimed */ protected Channel(Channel original) { this.descriptor = original.getDescriptor(); this.original = original.getOriginal(); assert this.original == null || !this.original.isCopy(); this.producer = original.getProducer(); this.producerSlot = original.getProducerSlot(); }
final OutputSlot<?> sourceOutput = sourceChannel.getProducerSlot(); final ExecutionOperator sourceOperator = (ExecutionOperator) sourceOutput.getOwner(); final LoopSubplan sourceLoop =
while (existingChannel.getProducerSlot() != sourceOutput) { existingChannel = OptimizationUtils.getPredecessorChannel(existingChannel);