mreutegg commented on code in PR #920:
URL: https://github.com/apache/jackrabbit-oak/pull/920#discussion_r1206764689
##########
oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/MongoDocumentStoreIT.java:
##########
@@ -268,4 +277,109 @@ public void queryWithNullProjection() {
docs.forEach(d -> assertEquals(4 , d.keySet().size()));
assertEquals(10, docs.size());
}
+
+ // OAK-10213
+ @Test
+ public void findAndUpdateBulk() {
+ DocumentStore docStore = mk.getDocumentStore();
+ DocumentNodeStore store =
builderProvider.newBuilder().setAsyncDelay(0).getNodeStore();
+ Revision rev = Revision.newRevision(0);
+ List<UpdateOp> inserts = new ArrayList<UpdateOp>();
+ for (int i = 0; i < 10; i++) {
+ DocumentNodeState n = new DocumentNodeState(store,
fromString("/node-" + i),
+ new RevisionVector(rev), of(new LongPropertyState("prop",
10L)), false, null);
+ inserts.add(n.asOperation(rev));
+ }
+ docStore.create(Collection.NODES, inserts);
+
+ List<UpdateOp> updateOps = new ArrayList<>(10);
+ for (int i = 0; i < 10; i++) {
+ UpdateOp updateOp = new UpdateOp(getIdFromPath(fromString("/node-"
+ i)), false);
+ updateOp.set("prop", 20L);
+ updateOp.contains("prop", true);
+ updateOps.add(updateOp);
+ }
+
+ List<NodeDocument> docs = docStore.findAndUpdate(NODES, updateOps);
+ assertEquals(10, docs.size());
+ docs.forEach(doc -> assertTrue(doc.isSealed()));
+ docs.forEach(d -> assertEquals(10L,
parseLong(d.getLocalMap("prop").get(d.getLocalMap("prop").firstKey()))));
+ }
+
+ @Test
+ public void findAndUpdateBulkNotFound() {
+ DocumentStore docStore = mk.getDocumentStore();
+ DocumentNodeStore store =
builderProvider.newBuilder().setAsyncDelay(0).getNodeStore();
+ Revision rev = Revision.newRevision(0);
+ List<UpdateOp> inserts = new ArrayList<UpdateOp>();
+ for (int i = 0; i < 10; i++) {
+ DocumentNodeState n = new DocumentNodeState(store,
fromString("/node-" + i),
+ new RevisionVector(rev), of(new LongPropertyState("prop",
10L)), false, null);
+ inserts.add(n.asOperation(rev));
+ }
+ docStore.create(Collection.NODES, inserts);
+
+ List<UpdateOp> updateOps = new ArrayList<>(10);
+ for (int i = 0; i < 10; i++) {
+ UpdateOp updateOp = new UpdateOp(getIdFromPath(fromString("/node-"
+ i)), false);
+ updateOp.set("prop", 20L);
+ updateOp.contains("prop", false);
+ updateOps.add(updateOp);
+ }
Review Comment:
Similar to previous comment. I think it would be better to base the
condition on a field that is not the sub document with the revision based prop
values. E.g. it could check if the _modified field is absent, which is never
the case here.
```suggestion
Revision updateRev = Revision.newRevision(0);
for (int i = 0; i < 10; i++) {
UpdateOp updateOp = new
UpdateOp(getIdFromPath(fromString("/node-" + i)), false);
updateOp.setMapEntry("prop", updateRev, "20");
updateOp.contains(MODIFIED_IN_SECS, false);
updateOps.add(updateOp);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]