Class CompositeTraversalBuilder

  • All Implemented Interfaces:
    TraversalBuilder, java.io.Serializable, scala.Equals, scala.Product, scala.Serializable

    public final class CompositeTraversalBuilder
    extends java.lang.Object
    implements TraversalBuilder, scala.Product, scala.Serializable
    INTERNAL API

    A generic builder that builds a traversal for graphs of arbitrary shape. The memory retained by this class usually decreases as ports are wired since auxiliary data is only maintained for ports that are unwired.

    This builder MUST construct its Traversal in the *exact* same order as its modules were added, since the first (and subsequent) input port of a module is implicitly assigned by its traversal order. Emitting Traversal nodes in a non-deterministic order (depending on wiring order) would mess up all relative addressing. This is the primary technical reason why a reverseTraversal list is maintained and the Traversal can only be completed once all output ports have been wired. See comments in akka.stream.impl.package for more details.

    param: reverseBuildSteps Keeps track of traversal steps that needs to be concatenated. This is basically a "queue" of BuilderKeys that point to builders of submodules/subgraphs. Since it is unknown in which order will the submodules "complete" (have all of their outputs assigned) we delay the creation of the actual Traversal. param: inSlots The number of input ports this graph has in total. param: inOffsets Map to look up the offset of input ports not yet wired param: inBaseOffsetForOut Map to look up the base (input) offset of a module that owns the given output port param: pendingBuilders Map to contain the "mutable" builders referred by BuilderKeys param: outOwners Map of output ports to their parent builders (actually the BuilderKey) param: unwiredOuts Number of output ports that have not yet been wired/assigned

    See Also:
    Serialized Form
    • Constructor Detail

    • Method Detail

      • $lessinit$greater$default$1

        public static Traversal $lessinit$greater$default$1()
      • $lessinit$greater$default$2

        public static scala.collection.immutable.List<TraversalBuildStep> $lessinit$greater$default$2()
      • $lessinit$greater$default$3

        public static int $lessinit$greater$default$3()
      • $lessinit$greater$default$4

        public static scala.collection.immutable.Map<InPort,​java.lang.Object> $lessinit$greater$default$4()
      • $lessinit$greater$default$5

        public static scala.collection.immutable.Map<OutPort,​java.lang.Object> $lessinit$greater$default$5()
      • $lessinit$greater$default$6

        public static scala.collection.immutable.Map<BuilderKey,​TraversalBuilder> $lessinit$greater$default$6()
      • $lessinit$greater$default$7

        public static scala.collection.immutable.Map<OutPort,​BuilderKey> $lessinit$greater$default$7()
      • $lessinit$greater$default$8

        public static int $lessinit$greater$default$8()
      • $lessinit$greater$default$10

        public static OptionVal<IslandTag> $lessinit$greater$default$10()
      • apply$default$1

        public static Traversal apply$default$1()
      • apply$default$2

        public static scala.collection.immutable.List<TraversalBuildStep> apply$default$2()
      • apply$default$3

        public static int apply$default$3()
      • apply$default$4

        public static scala.collection.immutable.Map<InPort,​java.lang.Object> apply$default$4()
      • apply$default$5

        public static scala.collection.immutable.Map<OutPort,​java.lang.Object> apply$default$5()
      • apply$default$7

        public static scala.collection.immutable.Map<OutPort,​BuilderKey> apply$default$7()
      • apply$default$8

        public static int apply$default$8()
      • traversal

        public static Traversal traversal()
      • reverseBuildSteps

        public scala.collection.immutable.List<TraversalBuildStep> reverseBuildSteps()
      • inSlots

        public int inSlots()
        Description copied from interface: TraversalBuilder
        The total number of input ports encountered so far. Gives the first slot to which a new input port can be assigned (if a new module is added).
        Specified by:
        inSlots in interface TraversalBuilder
        Returns:
        (undocumented)
      • inOffsets

        public scala.collection.immutable.Map<InPort,​java.lang.Object> inOffsets()
      • inBaseOffsetForOut

        public scala.collection.immutable.Map<OutPort,​java.lang.Object> inBaseOffsetForOut()
      • outOwners

        public scala.collection.immutable.Map<OutPort,​BuilderKey> outOwners()
      • unwiredOuts

        public int unwiredOuts()
        Description copied from interface: TraversalBuilder
        The number of output ports that have not been wired.
        Specified by:
        unwiredOuts in interface TraversalBuilder
        Returns:
        (undocumented)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • offsetOfModule

        public int offsetOfModule​(OutPort out)
        Description copied from interface: TraversalBuilder
        Returns the base offset (the first number an input port would receive if there is any) of the module to which the port belongs *relative to this builder*. This is used to calculate the relative offset of output port mappings (see MaterializeAtomic).

        This method only guarantees to return the offset of modules for output ports that have not been wired.

        Specified by:
        offsetOfModule in interface TraversalBuilder
        Parameters:
        out - (undocumented)
        Returns:
        (undocumented)
      • isUnwired

        public boolean isUnwired​(OutPort out)
        Description copied from interface: TraversalBuilder
        Returns whether the given output port has been wired in the graph or not.
        Specified by:
        isUnwired in interface TraversalBuilder
        Parameters:
        out - (undocumented)
        Returns:
        (undocumented)
      • isUnwired

        public boolean isUnwired​(InPort in)
        Description copied from interface: TraversalBuilder
        Returns whether the given input port has been wired in the graph or not.
        Specified by:
        isUnwired in interface TraversalBuilder
        Parameters:
        in - (undocumented)
        Returns:
        (undocumented)
      • offsetOf

        public int offsetOf​(InPort in)
        Description copied from interface: TraversalBuilder
        Returns the number assigned to a certain input port *relative* to this module.

        This method only guarantees to return the offset of input ports that have not been wired.

        Specified by:
        offsetOf in interface TraversalBuilder
        Parameters:
        in - (undocumented)
        Returns:
        (undocumented)
      • isTraversalComplete

        public boolean isTraversalComplete()
        Description copied from interface: TraversalBuilder
        Returns true if the Traversal is available. Not all builders are able to build up the Traversal incrementally. Generally a traversal is complete if there are no unwired output ports.
        Specified by:
        isTraversalComplete in interface TraversalBuilder
        Returns:
        (undocumented)
      • assign

        public TraversalBuilder assign​(OutPort out,
                                       int relativeSlot)
        Assign an output port a relative slot (relative to the base input slot of its module, see MaterializeAtomic)
        Specified by:
        assign in interface TraversalBuilder
        Parameters:
        out - (undocumented)
        relativeSlot - (undocumented)
        Returns:
        (undocumented)
      • add

        public TraversalBuilder add​(TraversalBuilder submodule,
                                    Shape shape,
                                    scala.Function2<scala.runtime.Nothing$,​scala.runtime.Nothing$,​java.lang.Object> combineMat)
        Description copied from interface: TraversalBuilder
        Adds a module to the builder. It is possible to add a module with a different Shape (import), in this case the ports of the shape MUST have their mappedTo field pointing to the original ports. The act of being imported will not be reflected in the final Traversal, the Shape is only used by the builder to disambiguate between multiple imported instances of the same module.

        See append in the LinearTraversalBuilder for a more efficient alternative for linear graphs.

        Specified by:
        add in interface TraversalBuilder
        Parameters:
        submodule - (undocumented)
        shape - (undocumented)
        combineMat - (undocumented)
        Returns:
        (undocumented)
      • wire

        public TraversalBuilder wire​(OutPort out,
                                     InPort in)
        Description copied from interface: TraversalBuilder
        Connects two unwired ports in the graph. For imported modules, use the ports of their "import shape". These ports must have their mappedTo field set and point to the original ports.

        See append in the LinearTraversalBuilder for a more efficient alternative for linear graphs.

        Specified by:
        wire in interface TraversalBuilder
        Parameters:
        out - (undocumented)
        in - (undocumented)
        Returns:
        (undocumented)
      • transformMat

        public TraversalBuilder transformMat​(scala.Function1<scala.runtime.Nothing$,​java.lang.Object> f)
        Description copied from interface: TraversalBuilder
        Maps the materialized value produced by the module built-up so far with the provided function, providing a new TraversalBuilder returning the mapped materialized value.
        Specified by:
        transformMat in interface TraversalBuilder
        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
      • makeIsland

        public TraversalBuilder makeIsland​(IslandTag islandTag)
        Description copied from interface: TraversalBuilder
        Wraps the builder in an island that can be materialized differently, using async boundaries to bridge between islands.
        Specified by:
        makeIsland in interface TraversalBuilder
        Parameters:
        islandTag - (undocumented)
        Returns:
        (undocumented)
      • copy$default$1

        public Traversal copy$default$1()
      • copy$default$2

        public scala.collection.immutable.List<TraversalBuildStep> copy$default$2()
      • copy$default$3

        public int copy$default$3()
      • copy$default$4

        public scala.collection.immutable.Map<InPort,​java.lang.Object> copy$default$4()
      • copy$default$5

        public scala.collection.immutable.Map<OutPort,​java.lang.Object> copy$default$5()
      • copy$default$7

        public scala.collection.immutable.Map<OutPort,​BuilderKey> copy$default$7()
      • copy$default$8

        public int copy$default$8()
      • copy$default$9

        public Attributes copy$default$9()
      • productPrefix

        public java.lang.String productPrefix()
        Specified by:
        productPrefix in interface scala.Product
      • productArity

        public int productArity()
        Specified by:
        productArity in interface scala.Product
      • productElement

        public java.lang.Object productElement​(int x$1)
        Specified by:
        productElement in interface scala.Product
      • productIterator

        public scala.collection.Iterator<java.lang.Object> productIterator()
        Specified by:
        productIterator in interface scala.Product
      • canEqual

        public boolean canEqual​(java.lang.Object x$1)
        Specified by:
        canEqual in interface scala.Equals
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object x$1)
        Specified by:
        equals in interface scala.Equals
        Overrides:
        equals in class java.lang.Object