Packages

o

fs2

pipe

object pipe

Generic implementations of common pipes.

Source
pipe.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. pipe
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. sealed trait Stepper [-A, +B] extends AnyRef

    Allows stepping of a pure pipe.

    Allows stepping of a pure pipe. Each invocation of step results in a value of the Stepper.Step algebra, indicating that the pipe is either done, it failed with an exception, it emitted a chunk of output, or it is awaiting input.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def buffer[F[_], I](n: Int): Pipe[F, I, I]

    Behaves like the identity function, but requests n elements at a time from the input.

  6. def bufferAll[F[_], I]: Pipe[F, I, I]

    Behaves like the identity stream, but emits no output until the source is exhausted.

  7. def bufferBy[F[_], I](f: (I) ⇒ Boolean): Pipe[F, I, I]

    Behaves like the identity stream, but requests elements from its input in blocks that end whenever the predicate switches from true to false.

  8. def changes[F[_], I]: Pipe[F, I, I]

    Emits only elements that are distinct from their immediate predecessors, using natural equality for comparison.

  9. def changesBy[F[_], I, I2](f: (I) ⇒ I2): Pipe[F, I, I]

    Emits only elements that are distinct from their immediate predecessors according to f, using natural equality for comparison.

    Emits only elements that are distinct from their immediate predecessors according to f, using natural equality for comparison.

    Note that f is called for each element in the stream multiple times and hence should be fast (e.g., an accessor). It is not intended to be used for computationally intensive conversions. For such conversions, consider something like: src.map(i => (i, f(i))).changesBy(_._2).map(_._1)

  10. def chunkLimit[F[_], I](n: Int): Pipe[F, I, NonEmptyChunk[I]]

    Outputs chunks with a limited maximum size, splitting as necessary.

  11. def chunkN[F[_], I](n: Int, allowFewer: Boolean = true): Pipe[F, I, List[NonEmptyChunk[I]]]

    Outputs a list of chunks, the total size of all chunks is limited and split as necessary.

  12. def chunks[F[_], I]: Pipe[F, I, NonEmptyChunk[I]]

    Outputs all chunks from the input Handle.

  13. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. def collect[F[_], I, I2](pf: PartialFunction[I, I2]): Pipe[F, I, I2]

    Map/filter simultaneously.

    Map/filter simultaneously. Calls collect on each Chunk in the stream.

  15. def collectFirst[F[_], I, I2](pf: PartialFunction[I, I2]): Pipe[F, I, I2]

    Emits the first element of the Stream for which the partial function is defined.

  16. def covary[F[_], I, O](s: Pipe[Pure, I, O]): Pipe[F, I, O]

    Converts a pure pipe to an effectful pipe of the specified type.

  17. def delete[F[_], I](p: (I) ⇒ Boolean): Pipe[F, I, I]

    Skips the first element that matches the predicate.

  18. def diamond[F[_], A, B, C, D](s: Stream[F, A])(f: Pipe[F, A, B])(qs: F[Queue[F, Option[Chunk[A]]]], g: Pipe[F, A, C])(combine: Pipe2[F, B, C, D])(implicit F: Async[F]): Stream[F, D]

    Pass elements of s through both f and g, then combine the two resulting streams.

    Pass elements of s through both f and g, then combine the two resulting streams. Implemented by enqueueing elements as they are seen by f onto a Queue used by the g branch. USE EXTREME CARE WHEN USING THIS FUNCTION. Deadlocks are possible if combine pulls from the g branch synchronously before the queue has been populated by the f branch.

    The combine function receives an F[Int] effect which evaluates to the current size of the g-branch's queue.

    When possible, use one of the safe combinators like observe, which are built using this function, in preference to using this function directly.

  19. def drop[F[_], I](n: Long): Pipe[F, I, I]

    Drops n elements of the input, then echoes the rest.

  20. def dropLast[F[_], I]: Pipe[F, I, I]

    Drops the last element.

  21. def dropLastIf[F[_], I](p: (I) ⇒ Boolean): Pipe[F, I, I]

    Drops the last element if the predicate evaluates to true.

  22. def dropRight[F[_], I](n: Int): Pipe[F, I, I]

    Emits all but the last n elements of the input.

  23. def dropWhile[F[_], I](p: (I) ⇒ Boolean): Pipe[F, I, I]

    Drops the elements of the input until the predicate p fails, then echoes the rest.

  24. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  25. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  26. def exists[F[_], I](p: (I) ⇒ Boolean): Pipe[F, I, Boolean]

    Emits true as soon as a matching element is received, else false if no input matches

  27. def filter[F[_], I](f: (I) ⇒ Boolean): Pipe[F, I, I]

    Emits only inputs which match the supplied predicate.

  28. def filterWithPrevious[F[_], I](f: (I, I) ⇒ Boolean): Pipe[F, I, I]

    Like filter, but the predicate f depends on the previously emitted and current elements.

  29. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  30. def find[F[_], I](f: (I) ⇒ Boolean): Pipe[F, I, I]

    Emits the first input (if any) which matches the supplied predicate, to the output of the returned Pull

  31. def fold[F[_], I, O](z: O)(f: (O, I) ⇒ O): Pipe[F, I, O]

    Folds all inputs using an initial value z and supplied binary operator, and emits a single element stream.

  32. def fold1[F[_], I](f: (I, I) ⇒ I): Pipe[F, I, I]

    Folds all inputs using the supplied binary operator, and emits a single-element stream, or the empty stream if the input is empty.

  33. def forall[F[_], I](p: (I) ⇒ Boolean): Pipe[F, I, Boolean]

    Emits a single true value if all input matches the predicate.

    Emits a single true value if all input matches the predicate. Halts with false as soon as a non-matching element is received.

  34. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  35. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  36. def id[F[_], I]: Pipe[F, I, I]

    Identity pipe - every input is output unchanged.

  37. def intersperse[F[_], I](separator: I): Pipe[F, I, I]

    Emits the specified separator between every pair of elements in the source stream.

  38. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  39. def join[F[_], A, B](s: Stream[F, Pipe[F, A, B]])(implicit arg0: Async[F]): Pipe[F, A, B]

    Joins a stream of pipes in to a single pipe.

    Joins a stream of pipes in to a single pipe. Input is fed to the first pipe until it terminates, at which point input is fed to the second pipe, and so on.

  40. def joinAsync[F[_], A, B](maxQueued: Int)(s: Stream[F, Pipe[F, A, B]])(implicit arg0: Async[F]): Pipe[F, A, B]

    Asynchronous version of join that queues up to maxQueued elements.

  41. def joinQueued[F[_], A, B](q: F[Queue[F, Option[Chunk[A]]]])(s: Stream[F, Pipe[F, A, B]])(implicit F: Async[F]): Pipe[F, A, B]

    Queue based version of join that uses the specified queue.

  42. def last[F[_], I]: Pipe[F, I, Option[I]]

    Returns the last element of the input Handle, if non-empty.

  43. def lastOr[F[_], I](li: ⇒ I): Pipe[F, I, I]

    Returns the last element of the input Handle if non-empty, otherwise li.

  44. def lift[F[_], I, O](f: (I) ⇒ O): Pipe[F, I, O]

    Applies the specified pure function to each input and emits the result.

    Applies the specified pure function to each input and emits the result. Works in a chunky fashion and creates a Chunk.indexedSeq for each mapped chunk.

  45. def mapAccumulate[F[_], S, I, O](init: S)(f: (S, I) ⇒ (S, O)): Pipe[F, I, (S, O)]

    Maps a running total according to S and the input with the function f.

    Maps a running total according to S and the input with the function f.

    Example:
    1. scala> Stream("Hello", "World")
           |   .mapAccumulate(0)((l, s) => (l + s.length, s.head)).toVector
      res0: Vector[(Int, Char)] = Vector((5,H), (10,W))
  46. def mapChunks[F[_], I, O](f: (Chunk[I]) ⇒ Chunk[O]): Pipe[F, I, O]

    Outputs a transformed version of all chunks from the input Handle.

  47. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  48. final def notify(): Unit
    Definition Classes
    AnyRef
  49. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  50. def observe[F[_], A](s: Stream[F, A])(sink: Sink[F, A])(implicit arg0: Async[F]): Stream[F, A]

    Synchronously send values through sink.

  51. def observeAsync[F[_], A](s: Stream[F, A], maxQueued: Int)(sink: Sink[F, A])(implicit arg0: Async[F]): Stream[F, A]

    Send chunks through sink, allowing up to maxQueued pending _chunks_ before blocking s.

  52. def prefetch[F[_], I](implicit arg0: Async[F]): Pipe[F, I, I]

    Behaves like id, but starts fetching the next chunk before emitting the current, enabling processing on either side of the prefetch to run in parallel.

  53. def rechunkN[F[_], I](n: Int, allowFewer: Boolean = true): Pipe[F, I, I]

    Modifies the chunk structure of the underlying stream, emitting potentially unboxed chunks of n elements.

    Modifies the chunk structure of the underlying stream, emitting potentially unboxed chunks of n elements. If allowFewer is true, the final chunk of the stream may be less than n elements. Otherwise, if the final chunk is less than n elements, it is dropped.

  54. def reduce[F[_], I](f: (I, I) ⇒ I): Pipe[F, I, I]

    Alias for pipe.fold1

  55. def rethrow[F[_], I]: Pipe[F, Attempt[I], I]

    Rethrows any Left(err).

    Rethrows any Left(err). Preserves chunkiness.

  56. def scan[F[_], I, O](z: O)(f: (O, I) ⇒ O): Pipe[F, I, O]

    Left fold which outputs all intermediate results.

    Left fold which outputs all intermediate results. Example: Stream(1,2,3,4) through pipe.scan(0)(_ + _) == Stream(0,1,3,6,10).

    More generally: Stream().scan(z)(f) == Stream(z) Stream(x1).scan(z)(f) == Stream(z, f(z,x1)) Stream(x1,x2).scan(z)(f) == Stream(z, f(z,x1), f(f(z,x1),x2)) etc

    Works in a chunky fashion, and creates a Chunk.indexedSeq for each converted chunk.

  57. def scan1[F[_], I](f: (I, I) ⇒ I): Pipe[F, I, I]

    Like pipe.scan, but uses the first element of the stream as the seed.

  58. def shiftRight[F[_], I](head: I*): Pipe[F, I, I]

    Emits the given values, then echoes the rest of the input.

  59. def sliding[F[_], I](n: Int): Pipe[F, I, Vector[I]]

    Groups inputs in fixed size chunks by passing a "sliding window" of size n over them.

    Groups inputs in fixed size chunks by passing a "sliding window" of size n over them. If the input contains less than or equal to n elements, only one chunk of this size will be emitted.

    Example:
    1. scala> Stream(1, 2, 3, 4).sliding(2).toList
      res0: List[Vector[Int]] = List(Vector(1, 2), Vector(2, 3), Vector(3, 4))
    Exceptions thrown

    scala.IllegalArgumentException if n <= 0

  60. def split[F[_], I](f: (I) ⇒ Boolean): Pipe[F, I, Vector[I]]

    Breaks the input into chunks where the delimiter matches the predicate.

    Breaks the input into chunks where the delimiter matches the predicate. The delimiter does not appear in the output. Two adjacent delimiters in the input result in an empty chunk in the output.

  61. def stepper[I, O](s: Pipe[Pure, I, O]): Stepper[I, O]

    Creates a Stepper, which allows incrementally stepping a pure pipe.

  62. def sum[F[_], I](implicit ev: Numeric[I]): Pipe[F, I, I]

    Writes the sum of all input elements, or zero if the input is empty.

  63. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  64. def tail[F[_], I]: Pipe[F, I, I]

    Emits all elements of the input except the first one.

  65. def take[F[_], I](n: Long): Pipe[F, I, I]

    Emits the first n elements of the input Handle and returns the new Handle.

  66. def takeRight[F[_], I](n: Long): Pipe[F, I, I]

    Emits the last n elements of the input.

  67. def takeThrough[F[_], I](f: (I) ⇒ Boolean): Pipe[F, I, I]

    Like takeWhile, but emits the first value which tests false.

  68. def takeWhile[F[_], I](f: (I) ⇒ Boolean): Pipe[F, I, I]

    Emits the longest prefix of the input for which all elements test true according to f.

  69. def toString(): String
    Definition Classes
    AnyRef → Any
  70. def unNoneTerminate[F[_], I]: Pipe[F, Option[I], I]

    Halts the input stream at the first None.

    Halts the input stream at the first None.

    Example:
    1. scala> Stream[Pure, Option[Int]](Some(1), Some(2), None, Some(3), None).unNoneTerminate.toList
      res0: List[Int] = List(1, 2)
  71. def unchunk[F[_], I]: Pipe[F, I, I]

    Converts the input to a stream of 1-element chunks.

  72. def vectorChunkN[F[_], I](n: Int, allowFewer: Boolean = true): Pipe[F, I, Vector[I]]

    Groups inputs into separate Vector objects of size n.

    Groups inputs into separate Vector objects of size n.

    Example:
    1. scala> Stream(1, 2, 3, 4, 5).vectorChunkN(2).toVector
      res0: Vector[Vector[Int]] = Vector(Vector(1, 2), Vector(3, 4), Vector(5))
  73. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  74. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  75. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  76. def zipWithIndex[F[_], I]: Pipe[F, I, (I, Int)]

    Zips the elements of the input Handle with its indices, and returns the new Handle

  77. def zipWithNext[F[_], I]: Pipe[F, I, (I, Option[I])]

    Zips the elements of the input Handle with its next element wrapped into Some, and returns the new Handle.

    Zips the elements of the input Handle with its next element wrapped into Some, and returns the new Handle. The last element is zipped with None.

  78. def zipWithPrevious[F[_], I]: Pipe[F, I, (Option[I], I)]

    Zips the elements of the input Handle with its previous element wrapped into Some, and returns the new Handle.

    Zips the elements of the input Handle with its previous element wrapped into Some, and returns the new Handle. The first element is zipped with None.

  79. def zipWithPreviousAndNext[F[_], I]: Pipe[F, I, (Option[I], I, Option[I])]

    Zips the elements of the input Handle with its previous and next elements wrapped into Some, and returns the new Handle.

    Zips the elements of the input Handle with its previous and next elements wrapped into Some, and returns the new Handle. The first element is zipped with None as the previous element, the last element is zipped with None as the next element.

  80. def zipWithScan[F[_], I, S](z: S)(f: (S, I) ⇒ S): Pipe[F, I, (I, S)]

    Zips the input with a running total according to S, up to but not including the current element.

    Zips the input with a running total according to S, up to but not including the current element. Thus the initial z value is the first emitted to the output:

    scala> Stream("uno", "dos", "tres", "cuatro").zipWithScan(0)(_ + _.length).toList
    res0: List[(String,Int)] = List((uno,0), (dos,3), (tres,6), (cuatro,10))
    See also

    zipWithScan1

  81. def zipWithScan1[F[_], I, S](z: S)(f: (S, I) ⇒ S): Pipe[F, I, (I, S)]

    Zips the input with a running total according to S, including the current element.

    Zips the input with a running total according to S, including the current element. Thus the initial z value is the first emitted to the output:

    scala> Stream("uno", "dos", "tres", "cuatro").zipWithScan(0)(_ + _.length).toList
    res0: List[(String,Int)] = List((uno,0), (dos,3), (tres,6), (cuatro,10))
    See also

    zipWithScan

  82. object Stepper

Inherited from AnyRef

Inherited from Any

Ungrouped