Trait/Object

reactivemongo.akkastream

Flows

Related Docs: object Flows | package akkastream

Permalink

sealed trait Flows[P <: SerializationPack, C <: GenericCollection[P]] extends AnyRef

Flow builder to stream data to MongoDB.

P

the type of the serialization pack of the target collection

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Flows
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract val collection: C

    Permalink

    The target collection

Concrete Value Members

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Flows[P, C] to any2stringadd[Flows[P, C]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Flows[P, C], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Flows[P, C] to ArrowAssoc[Flows[P, C]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def ensuring(cond: (Flows[P, C]) ⇒ Boolean, msg: ⇒ Any): Flows[P, C]

    Permalink
    Implicit information
    This member is added by an implicit conversion from Flows[P, C] to Ensuring[Flows[P, C]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  9. def ensuring(cond: (Flows[P, C]) ⇒ Boolean): Flows[P, C]

    Permalink
    Implicit information
    This member is added by an implicit conversion from Flows[P, C] to Ensuring[Flows[P, C]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: Boolean, msg: ⇒ Any): Flows[P, C]

    Permalink
    Implicit information
    This member is added by an implicit conversion from Flows[P, C] to Ensuring[Flows[P, C]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean): Flows[P, C]

    Permalink
    Implicit information
    This member is added by an implicit conversion from Flows[P, C] to Ensuring[Flows[P, C]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. final def eq(arg0: AnyRef): Boolean

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from Flows[P, C] to StringFormat[Flows[P, C]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  16. final def getClass(): Class[_]

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

    Permalink
    Definition Classes
    AnyRef → Any
  18. def insertMany[T](parallelism: Int, writeConcern: Option[WriteConcern] = None, bypassDocumentValidation: Boolean = false)(implicit w: P.Writer[T]): Flow[Iterable[T], C.MultiBulkWriteResult, NotUsed]

    Permalink

    Prepares a flow to orderedly insert batches in the specified collection.

    Prepares a flow to orderedly insert batches in the specified collection.

    parallelism

    the write parallelism

    writeConcern

    an optional write concern (if None the default one is used)

    bypassDocumentValidation

    if true bypass the document validation

    import akka.NotUsed
    import akka.stream.Materializer
    import akka.stream.scaladsl.{ Flow, Sink, Source }
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    import reactivemongo.akkastream.Flows
    def insert(
      coll: BSONCollection,
      src: => Source[BSONDocument, NotUsed]
    )(implicit m: Materializer) = {
      val flow: Flow[
        Iterable[BSONDocument],
        coll.MultiBulkWriteResult,
        NotUsed
      ] = Flows(coll).insertMany[BSONDocument](parallelism = 1)
      val batchSrc: Source[Iterable[BSONDocument], NotUsed] = src.grouped(128)
      batchSrc.via(flow).runWith(Sink.fold(0) { (c, res) => c + res.n })
    }
  19. def insertManyUnordered[T](parallelism: Int, writeConcern: Option[WriteConcern] = None, bypassDocumentValidation: Boolean = false)(implicit w: P.Writer[T]): Flow[Iterable[T], C.MultiBulkWriteResult, NotUsed]

    Permalink

    Prepares a flow to unorderedly insert batches in the specified collection.

    Prepares a flow to unorderedly insert batches in the specified collection.

    parallelism

    the write parallelism

    writeConcern

    an optional write concern (if None the default one is used)

    bypassDocumentValidation

    if true bypass the document validation

    import akka.NotUsed
    import akka.stream.Materializer
    import akka.stream.scaladsl.{ Sink, Source }
    import reactivemongo.api.bson.BSONDocumentWriter
    import reactivemongo.api.bson.collection.BSONCollection
    import reactivemongo.akkastream.Flows
    def insertUnordered[T](
      coll: BSONCollection,
      src: => Source[T, NotUsed]
    )(implicit m: Materializer, w: BSONDocumentWriter[T]) = {
      val batchSrc: Source[Iterable[T], NotUsed] = src.grouped(128)
      val builder = Flows(coll)
      batchSrc.via(builder.insertManyUnordered[T](parallelism = 10)).
        runWith(Sink.fold(0) { (c, res) => c + res.n })
    }
  20. def insertOne[T](parallelism: Int, writeConcern: Option[WriteConcern] = None, bypassDocumentValidation: Boolean = false)(implicit w: P.Writer[T]): Flow[T, WriteResult, NotUsed]

    Permalink

    Prepares a flow to orderedly insert documents in the specified collection.

    Prepares a flow to orderedly insert documents in the specified collection.

    parallelism

    the write parallelism

    writeConcern

    an optional write concern (if None the default one is used)

    bypassDocumentValidation

    if true bypass the document validation

    import akka.NotUsed
    import akka.stream.Materializer
    import akka.stream.scaladsl.{ Sink, Source }
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    import reactivemongo.akkastream.Flows
    def insert(
      coll: BSONCollection,
      src: => Source[BSONDocument, NotUsed]
    )(implicit m: Materializer) = {
      val flow = Flows(coll).insertOne[BSONDocument](parallelism = 1)
      src.via(flow).runWith(Sink.fold(0) { (c, res) => c + res.n })
    }
  21. def insertOneUnordered[T](parallelism: Int, writeConcern: Option[WriteConcern] = None, bypassDocumentValidation: Boolean = false)(implicit w: P.Writer[T]): Flow[T, WriteResult, NotUsed]

    Permalink

    Prepares a flow to orderedly insert documents in the specified collection.

    Prepares a flow to orderedly insert documents in the specified collection.

    parallelism

    the write parallelism

    writeConcern

    an optional write concern (if None the default one is used)

    bypassDocumentValidation

    if true bypass the document validation

    import akka.NotUsed
    import akka.stream.Materializer
    import akka.stream.scaladsl.{ Sink, Source }
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    import reactivemongo.akkastream.Flows
    def insert(
      coll: BSONCollection,
      src: => Source[BSONDocument, NotUsed]
    )(implicit m: Materializer) = {
      val flow = Flows(coll).insertOneUnordered[BSONDocument](parallelism = 10)
      src.via(flow).runWith(Sink.fold(0) { (c, res) => c + res.n })
    }
  22. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  23. final def ne(arg0: AnyRef): Boolean

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

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

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  28. def updateMany[T](parallelism: Int, writeConcern: Option[WriteConcern] = None, bypassDocumentValidation: Boolean = false)(element: (C.UpdateBuilder, T) ⇒ Future[C.UpdateElement]): Flow[Iterable[T], C.MultiBulkWriteResult, NotUsed]

    Permalink

    Prepares a flow to orderedly update batches in the specified collection.

    Prepares a flow to orderedly update batches in the specified collection.

    parallelism

    the write parallelism

    writeConcern

    an optional write concern (if None the default one is used)

    bypassDocumentValidation

    if true bypass the document validation

    element

    the function to prepare each update element from a T value

    See also

    reactivemongo.api.collections.GenericCollection.UpdateBuilder.element

    import akka.NotUsed
    import akka.stream.scaladsl.Flow
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    import reactivemongo.akkastream.Flows
    def myUpdateFlow(coll: BSONCollection): Flow[
      Iterable[(String, BSONDocument)],
      coll.MultiBulkWriteResult,
      NotUsed
    ] = Flows(coll).updateMany[(String, BSONDocument)](parallelism = 2) {
      case (upBuilder, (idStr, doc)) => upBuilder.element(
        q = BSONDocument("_id" -> idStr), u = doc,
        multi = false, upsert = true)
    }
  29. def updateManyUnordered[T](parallelism: Int, writeConcern: Option[WriteConcern] = None, bypassDocumentValidation: Boolean = false)(element: (C.UpdateBuilder, T) ⇒ Future[C.UpdateElement]): Flow[Iterable[T], C.MultiBulkWriteResult, NotUsed]

    Permalink

    Prepares a flow to orderedly update batches in the specified collection.

    Prepares a flow to orderedly update batches in the specified collection.

    parallelism

    the write parallelism

    writeConcern

    an optional write concern (if None the default one is used)

    bypassDocumentValidation

    if true bypass the document validation

    element

    the function to prepare each update element from a T value

    See also

    reactivemongo.api.collections.GenericCollection.UpdateBuilder.element

    import scala.concurrent.Future
    import akka.NotUsed
    import akka.stream.Materializer
    import akka.stream.scaladsl.{ Source, Sink }
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    import reactivemongo.akkastream.Flows
    def myUpdate(
      coll: BSONCollection,
      src: Source[(String, BSONDocument), NotUsed]
    )(implicit m: Materializer): Future[Int] = {
      import scala.language.existentials // required for 'flow' val bellow
      val flow = Flows(coll).
        updateManyUnordered[(String, BSONDocument)](parallelism = 2) {
          case (upBuilder, (idStr, doc)) => upBuilder.element(
            q = BSONDocument("_id" -> idStr), u = doc,
            multi = false, upsert = true)
          }
      src.grouped(10). // batching 10 per 10 updates
        via(flow).runWith(Sink.fold(0) { _ + _.n })
    }
  30. def updateOne[T](parallelism: Int, writeConcern: Option[WriteConcern] = None, bypassDocumentValidation: Boolean = false)(element: (C.UpdateBuilder, T) ⇒ Future[C.UpdateElement]): Flow[T, C.UpdateWriteResult, NotUsed]

    Permalink

    Prepares a flow to orderedly update documents in the specified collection.

    Prepares a flow to orderedly update documents in the specified collection.

    parallelism

    the write parallelism

    writeConcern

    an optional write concern (if None the default one is used)

    bypassDocumentValidation

    if true bypass the document validation

    element

    the function to prepare each update element from a T value

    Annotations
    @silent()
    See also

    reactivemongo.api.collections.GenericCollection.UpdateBuilder.element

    import akka.NotUsed
    import akka.stream.scaladsl.Flow
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    import reactivemongo.akkastream.Flows
    def myUpdateFlow(coll: BSONCollection): Flow[
      (String, BSONDocument),
      coll.UpdateWriteResult,
      NotUsed
    ] = Flows(coll).updateOne[(String, BSONDocument)](parallelism = 1) {
      case (upBuilder, (idStr, doc)) => upBuilder.element(
        q = BSONDocument("_id" -> idStr), u = doc,
        multi = false, upsert = true)
    }
  31. def updateOneUnordered[T](parallelism: Int, writeConcern: Option[WriteConcern] = None, bypassDocumentValidation: Boolean = false)(element: (C.UpdateBuilder, T) ⇒ Future[C.UpdateElement]): Flow[T, C.UpdateWriteResult, NotUsed]

    Permalink

    Prepares a flow to orderedly update batches in the specified collection.

    Prepares a flow to orderedly update batches in the specified collection.

    parallelism

    the write parallelism

    writeConcern

    an optional write concern (if None the default one is used)

    bypassDocumentValidation

    if true bypass the document validation

    element

    the function to prepare each update element from a T value

    Annotations
    @silent()
    See also

    reactivemongo.api.collections.GenericCollection.UpdateBuilder.element

    import scala.concurrent.Future
    import akka.NotUsed
    import akka.stream.Materializer
    import akka.stream.scaladsl.{ Source, Sink }
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    import reactivemongo.akkastream.Flows
    def myUpdate(
      coll: BSONCollection,
      src: Source[(String, BSONDocument), NotUsed]
    )(implicit m: Materializer): Future[Int] = {
      import scala.language.existentials // required for 'flow' val bellow
      val flow = Flows(coll).
        updateOneUnordered[(String, BSONDocument)](parallelism = 10) {
          case (upBuilder, (idStr, doc)) => upBuilder.element(
            q = BSONDocument("_id" -> idStr), u = doc,
            multi = false, upsert = true)
          }
      src.via(flow).runWith(Sink.fold(0) { _ + _.n })
    }
  32. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. def [B](y: B): (Flows[P, C], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from Flows[P, C] to ArrowAssoc[Flows[P, C]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from Flows[P, C] to any2stringadd[Flows[P, C]]

Inherited by implicit conversion StringFormat from Flows[P, C] to StringFormat[Flows[P, C]]

Inherited by implicit conversion Ensuring from Flows[P, C] to Ensuring[Flows[P, C]]

Inherited by implicit conversion ArrowAssoc from Flows[P, C] to ArrowAssoc[Flows[P, C]]

Ungrouped