private void copyEdgesFrom(TreeVertex that) { assert this.channelDescriptor.equals(that.channelDescriptor); this.outEdges.addAll(that.outEdges); }
@Override public String toString() { return String.format("%s[%s,%s%s]", this.getClass().getSimpleName(), this.getChannelClass().getSimpleName(), this.isReusable() ? "r" : "-", this.isSuitableForBreakpoint() ? "b" : "-" ); }
@Override public int hashCode() { return Objects.hash(super.hashCode(), this.location, this.serialization); } }
if (channelDescriptor.isReusable() || newSettledIndices.cardinality() == 1) { if (channelDescriptor.isReusable()) { targetChannelDescriptor, settledDestinationIndices, isVisitedBreakpointChannel || targetChannelDescriptor.isSuitableForBreakpoint() ); childSolutions.values().forEach( tree -> tree.reroot( channelDescriptor, channelDescriptor.isReusable() ? newSettledIndices : Bitmask.EMPTY_BITMASK, channelConversion, this.getCostEstimate(channelConversion) if (channelDescriptor.isReusable() && this.kernelDestChannelDescriptorSetsToIndices.size() > 1 && childSolutionSets.size() > 1
/** * Creates a new {@link Channel} as described by this instance. * * @param configuration can provide additional information required for the creation * @return the {@link Channel} */ public Channel createChannel(OutputSlot<?> output, Configuration configuration) { Class<? extends Channel> channelClass = this.getChannelClass(); try { final Constructor<? extends Channel> constructor = channelClass.getConstructor(ChannelDescriptor.class, OutputSlot.class); return constructor.newInstance(this, output); } catch (Exception e) { throw new UnsupportedOperationException( String.format("Default channel creation is not working for %s. Please override.", this.getChannelClass().getSimpleName()), e ); } } }
/** * Declares whether this is not a read-once instance. * * @return whether this instance can have multiple consumers */ public boolean isReusable() { return this.getDescriptor().isReusable(); }
public Channel initializeOutputChannel(int index, Configuration configuration) { final ChannelDescriptor channelDescriptor = this.operator.getOutputChannelDescriptor(index); final OutputSlot<?> output = this.operator.getNumOutputs() == 0 ? null : this.operator.getOutput(index); final Channel channel = channelDescriptor.createChannel(output, configuration); this.setOutputChannel(index, channel); return channel; }
/** * Tells whether this instance lends itself for {@link Breakpoint}s. That is particularly the case if: * <ol> * <li>it is produced immediately by its producer ({@link #getProducer()};</li> * <li>the contained data are at rest;</li> * <li>and, as a bonus, the cardinality of the data can be observed.</li> * </ol> * * @return whether this instance lends itself for {@link Breakpoint}s */ public boolean isSuitableForBreakpoint() { return this.getDescriptor().isSuitableForBreakpoint(); }
@Override public String toString() { return String.format("%s[%s->%s]", this.getClass().getSimpleName(), this.getSourceChannelDescriptor().getChannelClass().getSimpleName(), this.getTargetChannelDescriptor().getChannelClass().getSimpleName() ); } }
iterator.remove(); channelDescriptors = new HashSet<>(channelDescriptors); channelDescriptors.removeIf(channelDescriptor -> !channelDescriptor.isReusable()); kernelDestChannelDescriptorSetsToIndicesUpdates.add(new Tuple<>(channelDescriptors, indices));
Channel sourceChannel = this.existingChannels.get(this.sourceChannelDescriptor); if (sourceChannel == null) { sourceChannel = this.sourceChannelDescriptor.createChannel(this.sourceOutput, this.optimizationContext.getConfiguration());
/** * Starts the actual search. */ private Tree searchTree() { // Prepare the recursive traversal. final HashSet<ChannelDescriptor> visitedChannelDescriptors = new HashSet<>(16); visitedChannelDescriptors.add(this.sourceChannelDescriptor); // Perform the traversal. final Map<Bitmask, Tree> solutions = this.enumerate( visitedChannelDescriptors, this.sourceChannelDescriptor, Bitmask.EMPTY_BITMASK, this.sourceChannelDescriptor.isSuitableForBreakpoint() ); // Get hold of a comprehensive solution (if it exists). Bitmask requestedIndices = new Bitmask(this.destChannelDescriptorSets.size()); requestedIndices.flip(0, this.destChannelDescriptorSets.size()); return solutions.get(requestedIndices); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; if (!super.equals(o)) return false; Descriptor that = (Descriptor) o; return Objects.equals(this.location, that.location) && Objects.equals(this.serialization, that.serialization); }
(k, v) -> v == null ? new Bitmask(channelIndices) : v.orInPlace(channelIndices) ); if (existingDestinationChannel.getDescriptor().equals(this.sourceChannelDescriptor)) break; existingDestinationChannel = OptimizationUtils.getPredecessorChannel(existingDestinationChannel);