Specify the MapReduceAction
to be used when writing to a collection.
Specify the MapReduceAction
to be used when writing to a collection.
an model.MapReduceAction to perform on the collection
this
Applies the side-effecting function to the final result of this Observable and, returns a new Observable with the result of this Observable.
Applies the side-effecting function to the final result of this Observable and, returns a new Observable with the result of this Observable.
This method allows one to enforce that the callbacks are executed in a specified order.
Note that if one of the chained andThen
callbacks throws an exception, that exception is not propagated to the subsequent
andThen
callbacks. Instead, the subsequent andThen
callbacks are given the original value of this Observable.
The following example prints out 10
:
Observable(1 to 10) andThen { case r => sys.error("runtime exception") } andThen { case Success(x) => print(x) case Failure(t) => print("Failure") }
the result type of the
the partial function to pattern match against
an
Sets the number of documents to return per batch.
Sets the number of documents to return per batch.
the batch size
this
2.7
Sets the bypass document level validation flag.
Sets the bypass document level validation flag.
Note:: This only applies when an $out
stage is specified.
If true, allows the write to opt-out of document level validation.
this
1.1
Requires MongoDB 3.2 or greater
Sets the collation options
Sets the collation options
the collation options to use
this
1.2
Requires MongoDB 3.4 or greater
,A null value represents the server default.
Collects all the values of the Observable into a list and returns a new Observable with that list.
Collects all the values of the Observable into a list and returns a new Observable with that list.
Example:
val listOfNumbers = Observable(1 to 100).collect()
an Observable that emits a single item, the result of accumulator.
If the Observable is large then this will consume lots of memory! If the underlying Observable is infinite this Observable will never complete.
Uses foldLeft underneath
Sets the collectionName for the output of the MapReduce
Sets the collectionName for the output of the MapReduce
The default action is replace the collection if it exists, to change this use action.
the name of the collection that you want the map-reduce operation to write its output.
this
Sets the name of the database to output into.
Sets the name of the database to output into.
the name of the database to output into.
this
Creates a new Observable which returns the results of this Observable, if there is an error, it will then fallback to returning
the results of the alternative "that
" Observable.
Creates a new Observable which returns the results of this Observable, if there is an error, it will then fallback to returning
the results of the alternative "that
" Observable.
If both Observables fail, the resulting Observable holds the throwable object of the first Observable.
Example:
val fallBackObservable = Observable(1 to 100) fallbackTo Observable(200 to 300)
fallbackTo
can potentially emit results from either Observer. This often isn't desirable, so to ensure only a single Observable
issues results combine with the collect method eg:
val results = Observable(1 to 100).collect() fallbackTo Observable(200 to 300).collect()
the type of the returned Observable
the Observable to fallback to if this
Observable fails
an Observable that will fallback to the that
Observable should this
Observable complete with an onError
.
Sets the query filter to apply to the query.
Sets the query filter to apply to the query.
the filter to apply to the query.
this
Creates a new Observable by filtering the value of the current Observable with a predicate.
Creates a new Observable by filtering the value of the current Observable with a predicate.
If the current Observable fails, then the resulting Observable also fails.
Example:
val oddValues = Observable(1 to 100) filter { _ % 2 == 1 }
the function that is applied to each result emitted if it matches that result is passes to the returned Observable
an Observable only containing items matching that match the predicate
Sets the JavaScript function that follows the reduce method and modifies the output.
Sets the JavaScript function that follows the reduce method and modifies the output.
the JavaScript function that follows the reduce method and modifies the output.
this
Helper to return a single observable limited to the first result.
Helper to return a single observable limited to the first result.
a single observable which will the first result.
4.0
Creates a new Observable by applying a function to each emitted result of the Observable.
Creates a new Observable by applying a function to each emitted result of the Observable. If the Observable calls errors then then the new Observable will also contain this exception.
As each emitted item passed to onNext
returns an Observable, we tightly control the requests to the parent Observable.
The requested amount is then passed to the child Observable and only when that is completed does the parent become available for
requesting more data.
Example:
def f = Observable(1 to 10) def g = Observable(100 to 100) val h = for { x: Int <- f // returns Observable(1 to 10) y: Int <- g // returns Observable(100 to 100) } yield x + y
is translated to:
f flatMap { (x: Int) => g map { (y: Int) => x + y } }
the resulting type of each item in the Observable
function that transforms a each result of the receiver into an Observable and passes each result of that Observable to the returned Observable.
an Observable with transformed results and / or error.
Creates a new Observable that contains the single result of the applied accumulator function.
Creates a new Observable that contains the single result of the applied accumulator function.
The first item emitted by the Observable is passed to the supplied accumulator function alongside the initial value, then all other emitted items are passed along with the previous result of the accumulator function.
Example:
val countingObservable = Observable(1 to 100) foldLeft(0)((v, i) => v + 1)
the initial (seed) accumulator value
an accumulator function to be invoked on each item emitted by the source Observable, the result of which will be used in the next accumulator call.
an Observable that emits a single item, the result of accumulator.
If this function is used to collect results into a collection then it could use lots of memory! If the underlying Observable is infinite this Observable will never complete.
Applies a function applied to each emitted result.
Applies a function applied to each emitted result.
Automatically requests all results
the resulting type after the transformation
the anonymous function applied to each emitted item
Returns the head of the Observable in a scala.concurrent.Future.
Returns the head of the Observable in a scala.concurrent.Future.
the head result of the Observable.
Returns the head option of the Observable in a scala.concurrent.Future.
Returns the head option of the Observable in a scala.concurrent.Future.
the head option result of the Observable.
2.2
Sets the flag that specifies whether to convert intermediate data into BSON format between the execution of the map and reduce functions.
Sets the flag that specifies whether to convert intermediate data into BSON format between the execution of the map and reduce functions. Defaults to false.
the flag that specifies whether to convert intermediate data into BSON format between the execution of the map and reduce functions
jsMode
Sets the limit to apply.
Sets the limit to apply.
the limit, which may be null
this
Creates a new Observable by applying a function to each emitted result of the Observable.
Creates a new Observable by applying a function to each emitted result of the Observable. If the Observable calls errors then then the new Observable will also contain this exception.
Example:
def f = Observable(1 to 10) def g = Observable(100 to 100) val h = for { x: Int <- f // returns Observable(1 to 10) y: Int <- g // returns Observable(100 to 100) } yield x + y
is translated to:
f flatMap { (x: Int) => g map { (y: Int) => x + y } }
the resulting type of each item in the Observable
function that transforms a each result of the receiver and passes the result to the returned Observable
an Observable with transformed results and / or error.
Sets the maximum execution time on the server for this operation.
Sets the maximum execution time on the server for this operation.
the duration
this
Use a specific execution context for future operations
Use a specific execution context for future operations
the execution context
an Observable that uses the specified execution context
Creates a new Observable that will handle any matching throwable that this Observable might contain.
Creates a new Observable that will handle any matching throwable that this Observable might contain. If there is no match, or if this Observable contains a valid result then the new Observable will contain the same.
Example:
mongoExceptionObservable recover { case e: MongoException => 0 } // final result: 0 mongoExceptionObservable recover { case e: NotFoundException => 0 } // result: exception
the type of the returned Observable
the partial function used to pattern match against the onError
throwable
an Observable that will handle any matching throwable and not error.
Creates a new Observable that will handle any matching throwable that this Observable might contain by assigning it a value of another Observable.
Creates a new Observable that will handle any matching throwable that this Observable might contain by assigning it a value of another Observable.
If there is no match, or if this Observable contains a valid result then the new Observable will contain the same result.
Example:
successfulObservable recoverWith { case e: ArithmeticException => observableB } // result: successfulObservable mongoExceptionObservable recoverWith { case t: Throwable => observableB } // result: observableB
recoverWith
can potentially emit results from either Observer. This often isn't desirable, so to ensure only a single Observable
issues results combine with the collect method eg:
val results = Observable(1 to 100) .collect() .recoverWith({ case t: Throwable => Observable(200 to 300).collect() }) .subscribe((i: Seq[Int]) => print(results))
the type of the returned Observable
the partial function used to pattern match against the onError
throwable
an Observable that will handle any matching throwable and not error but recover with a new observable
Sets the global variables that are accessible in the map, reduce and finalize functions.
Sets the global variables that are accessible in the map, reduce and finalize functions.
the global variables that are accessible in the map, reduce and finalize functions.
this
Sets the sort criteria to apply to the query.
Sets the sort criteria to apply to the query.
the sort criteria, which may be null.
this
Request Observable
to start streaming data.
Request Observable
to start streaming data.
This is a "factory method" and can be called multiple times, each time starting a new Subscription.
Each Subscription
will work for only a single Observer.
If the Observable
rejects the subscription attempt or otherwise fails it will signal the error via Observer.onError.
the Observer
that will consume signals from this Observable
Subscribes to the Observable and requests Long.MaxValue
.
Subscribes to the Observable and requests Long.MaxValue
.
Uses the default or overridden onNext
, onError
, onComplete
partial functions.
anonymous function to apply to each emitted element.
anonymous function to apply if there is an error.
anonymous function to apply on completion.
Subscribes to the Observable and requests Long.MaxValue
.
Subscribes to the Observable and requests Long.MaxValue
.
anonymous function to apply if there is an error.
anonymous function to apply on completion.
Subscribes to the Observable and requests Long.MaxValue
.
Subscribes to the Observable and requests Long.MaxValue
.
anonymous function to apply to each emitted element.
anonymous function to apply if there is an error.
Subscribes to the Observable and requests Long.MaxValue
.
Subscribes to the Observable and requests Long.MaxValue
.
anonymous function to apply to each emitted element.
Handles the automatic boxing of a Java Observable
so it conforms to the interface.
Handles the automatic boxing of a Java Observable
so it conforms to the interface.
the Observer
that will consume signals from this Observable
Users should not have to implement this method but rather use the Scala Observable
.
Aggregates documents to a collection according to the specified map-reduce function with the given options, which must specify a non-inline result.
Aggregates documents to a collection according to the specified map-reduce function with the given options, which must specify a non-inline result.
an empty Observable that indicates when the operation has completed Aggregation
Creates a new Observable by applying the resultFunction
function to each emitted result.
Creates a new Observable by applying the resultFunction
function to each emitted result.
If there is an error and onError
is called the errorFunction
function is applied to the failed result.
the resulting type of each item in the Observable
function that transforms a each result of the receiver and passes the result to the returned Observable
function that transforms a failure of the receiver into a failure of the returned observer
an Observable with transformed results and / or error.
Sets whether to include the timing information in the result information.
Sets whether to include the timing information in the result information.
whether to include the timing information in the result information.
this
Used by for-comprehensions.
Used by for-comprehensions.
Zips the values of this
and that
Observable, and creates a new Observable holding the tuple of their results.
Zips the values of this
and that
Observable, and creates a new Observable holding the tuple of their results.
If this
Observable fails, the resulting Observable is failed with the throwable stored in this
. Otherwise, if that
Observable fails, the resulting Observable is failed with the throwable stored in that
.
It will only emit as many items as the number of items emitted by the source Observable that emits the fewest items.
the type of the that
Observable
the Observable to zip with
a new zipped Observable
(Since version ) see corresponding Javadoc for more information.
Sets if the post-processing step will prevent MongoDB from locking the database.
Sets if the post-processing step will prevent MongoDB from locking the database.
Valid only with the MapReduceAction.MERGE
or MapReduceAction.REDUCE
actions.
if the post-processing step will prevent MongoDB from locking the database.
this
(Since version 4.1.0) This option will no longer be supported in MongoDB 4.4 as it will no longer hold a global or database level write lock
Sets if the output database is sharded
Sets if the output database is sharded
if the output database is sharded
this
(Since version 4.1.0) This option will no longer be supported in MongoDB 4.4.
Observable for map reduce.