Class

com.github.mboogerd.streams.sorted

ContiguousGroupBy

Related Doc: package sorted

Permalink

final class ContiguousGroupBy[T, K] extends GraphStage[FlowShape[T, (K, Source[T, NotUsed])]]

A group-by specifically written for streams that are contiguous w.r.t. the computed key. Sorted-stream is a sufficient, but not a necessary condition for this to work. Informally, what matters is that all elements that map to the same key form groups of consecutive elements, i.e:

for-all s, t in inputstream, such that s precedes t directly: if keyFor(s) != keyFor(t), then: - there exists no element u in inputstream such that t precedes u (at any distance) s.t. keyFor(s) == keyFor(u); and, - there exists no element r in inputstream such that r precedes s (at any distance) s.t. keyFor(r) == keyFor(t).

All groups of stream-elements are propagated to their own substream. What distinguishes this implementation from the typical group-by implementation is that sub-streams can be closed directly after witnessing a value that maps to a different key. The traditional group-by must keep all sub-streams open until the superstream is consumed, as only then it can guarantee that no more elements will be propagated to any of the sub-streams. Resources can be freed immediately, given the guarantee that no more elements will arrive for the substream.

An contiguous approach (if the stream permits it) allows you to stay closer to business-semantics; There is no need to specify how many groups may be processed concurrently. Also, we have more (but not complete) freedom to wait in our superstream for completion of a substream, without introducing deadlocks. Both these permit us to use a declarative group-by, where otherwise this logic would be obfuscated by stream-management.

Linear Supertypes
GraphStage[FlowShape[T, (K, Source[T, NotUsed])]], GraphStageWithMaterializedValue[FlowShape[T, (K, Source[T, NotUsed])], NotUsed], Graph[FlowShape[T, (K, Source[T, NotUsed])], NotUsed], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ContiguousGroupBy
  2. GraphStage
  3. GraphStageWithMaterializedValue
  4. Graph
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ContiguousGroupBy(keyFor: (T) ⇒ K)

    Permalink

Type Members

  1. type Shape = FlowShape[T, (K, Source[T, NotUsed])]

    Permalink
    Definition Classes
    Graph

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def addAttributes(attr: Attributes): Graph[FlowShape[T, (K, Source[T, NotUsed])], NotUsed]

    Permalink
    Definition Classes
    Graph
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def async: Graph[FlowShape[T, (K, Source[T, NotUsed])], NotUsed]

    Permalink
    Definition Classes
    Graph
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def createLogic(inheritedAttributes: Attributes): GraphStageLogic

    Permalink
    Definition Classes
    ContiguousGroupBy → GraphStage
  9. final def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, NotUsed)

    Permalink
    Definition Classes
    GraphStage → GraphStageWithMaterializedValue
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. val in: Inlet[T]

    Permalink
  16. def initialAttributes: Attributes

    Permalink
    Definition Classes
    ContiguousGroupBy → GraphStageWithMaterializedValue
  17. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  18. val maxSubstreams: Int

    Permalink
  19. final lazy val module: Module

    Permalink
    Definition Classes
    GraphStageWithMaterializedValue → Graph
  20. def named(name: String): Graph[FlowShape[T, (K, Source[T, NotUsed])], NotUsed]

    Permalink
    Definition Classes
    Graph
  21. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  22. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  23. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. val out: Outlet[(K, Source[T, NotUsed])]

    Permalink
  25. val shape: FlowShape[T, (K, Source[T, NotUsed])]

    Permalink
    Definition Classes
    ContiguousGroupBy → Graph
  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  27. def toString(): String

    Permalink
    Definition Classes
    ContiguousGroupBy → AnyRef → Any
  28. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def withAttributes(attr: Attributes): Graph[FlowShape[T, (K, Source[T, NotUsed])], NotUsed]

    Permalink
    Definition Classes
    GraphStageWithMaterializedValue → Graph

Inherited from GraphStage[FlowShape[T, (K, Source[T, NotUsed])]]

Inherited from GraphStageWithMaterializedValue[FlowShape[T, (K, Source[T, NotUsed])], NotUsed]

Inherited from Graph[FlowShape[T, (K, Source[T, NotUsed])], NotUsed]

Inherited from AnyRef

Inherited from Any

Ungrouped