如何使用 AsynCluster 在 Couchbase 中进行批量(使用选择更新)处理,而不在 couchbase SDK 3.x 中使用反应式?
我有一个要求,我想更新 Couchbase 中的 1000 条记录并获取更新记录的 id。我不想使用couchbase SDK 3.x官方文档中提到的Reactive(项目反应器)。
还有另一种方法,我们可以在服务端使用 CompletableFuture 并调用 AsynCluster.query(queryStatment) ,它也返回 CompletableFuture
有没有办法执行 1000 更新(准确地说是选择“UPDATE bucketName SET docType = 'abc'”WHERE caseId = 123 RETURNING caseId as caseId ;”更新)操作并返回 caseID 并异步执行此任务。
我尝试过下面的代码,但不确定它
List <CompletableFuture<QueryResult>> completableFutureList = new ArrayList<>();
for(JsonObject j : jsonObjectList) {
completableFutureList.add(asyncCluster.query(queryStatement,
QueryOptions.queryOptions().parameters(j)));}
CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0]))
.exceptionally(ex-> null).join();
应该异步工作并返回成功更新的 caseId 列表,并处理执行更新操作和捕获时发生的任何异常。分别那个。
I have a requirement where I want to update 1000 records in the Couchbase and get the ids of the updated record back. I don't want to use Reactive (project reactor) as mentioned in the official document of couchbase SDK 3.x.
there is one more approach where we can use the CompletableFuture on the service side and call the AsynCluster.query(queryStatment) which also return CompletableFuture<QueryResult> back.
is there any way to perform 1000 update(to be precise update with select "UPDATE bucketName SET docType = 'abc' "WHERE caseId = 123 RETURNING caseId as caseId ;") operation and return caseID back and do this task asynchronously.
i tried with below code but not sure about it.
List <CompletableFuture<QueryResult>> completableFutureList = new ArrayList<>();
for(JsonObject j : jsonObjectList) {
completableFutureList.add(asyncCluster.query(queryStatement,
QueryOptions.queryOptions().parameters(j)));}
CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0]))
.exceptionally(ex-> null).join();
it should work asynchronously and return the list of caseIds that are successfully updated and also handle any exception that occurred while doing the update operation and catch that separately.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论