Ordered Updates/Writes

Hi folks ,

When we retry to do replace operation to a collection , with 10k documents which are present in a arrayList, will the order be maintained in collections?

   Flux.fromIterable(events).flatMap(document -> reactiveCollection.replace(document.key,document.data).onErrorResume(e -> {
            erroredResults.put(document, e);
            return Mono.empty();
        })).doOnNext(successfulResults::add).blockLast();

im using bulk operation method via the reactive java lib, will the replace operations done parrallely for the documents , or will the order of documents in the list will be maintained in the collection too?

please give some information on the order scenarios.

Thanks

Hi @Karthikeyan

im using bulk operation method via the reactive java lib, will the replace operations done parrallely for the documents

That depends totally on how you use the reactive API - you have the option to do operations in parallel or in whatever order you wish. Your code there is using flatMap which does do operations in parallel by default. You can use concatMap if you want things serialised instead.

This is purely personal preference, but I like to use .runOn() and .parallel() rather than .flatMap(), to make the parallelism explicit.

As for the rest of your question, regarding document ordering, I’ll assume you’re talking about reading documents using a SQL++ query. Here the ordering will be defined by the index and/or any ORDER BY constraints, both of which are defined by you. How you write the documents is unrelated to that ordering.