I have this piece of code using SDK v2
bucket.async().query(N1qlQuery.simple("SELECT META().id FROM example"))
.flatMap(AsyncN1qlQueryResult::rows)
.flatMap(row -> bucket.async().get(row.value().getString("id"))
.map(d -> {
System.out.println("map: " + Thread.currentThread().getName());
return d;
})).toList().toBlocking().single();
this prints:
map: cb-computations-2
map: cb-computations-1
map: cb-computations-3
map: cb-computations-4
map: cb-rcomputations-8
...
so the map function is automatically run on multiple computation threads.
I tried to translate this code into V3: (3.0.8)
cluster.reactive().query("SELECT META().id FROM example")
.flatMapMany(ReactiveQueryResult::rowsAsObject)
.flatMap(row -> bucket.reactive().defaultCollection().get(row.getString("id"))
.map(d -> {
System.out.println("map: " + Thread.currentThread().getName());
return d;
})).collectList().block();
and this prints:
map: cb-io-kv-5-2
map: cb-io-kv-5-2
map: cb-io-kv-5-2
map: cb-io-kv-5-2
....
Why is the map executed on io threads and only on single thread? How would I get the same behaviour as in V2 SDK?