[英]Couchbase bulk subdocument operation
我正在使用Couchbase-Java SDK 2.7.1並嘗試對文檔密鑰集執行批量子網操作。 下面的代碼沒有拋出任何錯誤,但在執行給定代碼后文檔沒有得到更新。
/*
Document structure:
{
"key1": "",
"key2:: ""
}
*/
List<String> docIds = new ArrayList<String>();
docIds.add("mydoc-1");
docIds.add("mydoc-2");
String docPath = "key1";
String value = "myVal";
Observable<String> docIdsObs = Observable.from(docIds);
Observable<DocumentFragment<Mutation>>
subdocAppendObs =
docIdsObs.flatMap(docId -> this.subdocUpsert(bucket, docId, docPath, value,
persist, replicate, timeout,
timeunit));
正如dnault在評論中所建議的那樣,你並沒有觸發Observable
實際開始操作。 執行流程將設置Observable
並繼續,因此如果完全存在,您的應用程序將退出。
如果您的app設計為異步使用輸出,則只需添加subscribe
一個變體即可。
如果你想阻止操作完成,你想要使用倒計時鎖存器,或者你可以做類似的事情
List<DocumentFragment<Mutation>> result = docIdsObs.flatMap(docId -> this.subdocUpsert(bucket, docId, docPath, value,
persist, replicate, timeout,
timeunit));
.toList()
.toBlocking()
.single();
這將阻止並在單個列表中生成所有結果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.