Created
February 1, 2018 18:08
-
-
Save daschl/6c7fac9a11c1896b9ff5f8d25d01d8dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Scope scope = env.tracer() | |
.buildSpan("query-and-fetch") | |
.startActive(true); | |
bucket.async() | |
.query(N1qlQuery.simple("select meta().id as id from `travel-sample` limit 10"), scope.span()) | |
.flatMap(new Func1<AsyncN1qlQueryResult, Observable<AsyncN1qlQueryRow>>() { | |
public Observable<AsyncN1qlQueryRow> call(AsyncN1qlQueryResult result) { | |
return result.rows(); | |
} | |
}).flatMap(new Func1<AsyncN1qlQueryRow, Observable<JsonDocument>>() { | |
public Observable<JsonDocument> call(AsyncN1qlQueryRow row) { | |
return bucket.async().get(row.value().getString("id"), scope.span(), JsonDocument.class); | |
} | |
}) | |
.toBlocking() | |
.last(); | |
scope.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment