|
3 | 3 | import java.util.List; |
4 | 4 | import java.util.UUID; |
5 | 5 | import java.util.function.Function; |
| 6 | +import java.util.stream.Collectors; |
6 | 7 | import java.util.stream.Stream; |
7 | 8 |
|
8 | 9 | import de.bwaldvogel.mongo.MongoBackend; |
@@ -39,29 +40,32 @@ public void handleInsert(String namespace, List<Document> documents) { |
39 | 40 | if (isOplogCollection(namespace)) { |
40 | 41 | return; |
41 | 42 | } |
42 | | - documents.stream() |
| 43 | + final List<Document> oplogInsertDocuments = documents.stream() |
43 | 44 | .map(document -> toOplogInsertDocument(namespace, document)) |
44 | | - .forEach(collection::addDocument); |
| 45 | + .collect(Collectors.toList()); |
| 46 | + collection.addDocuments(oplogInsertDocuments); |
45 | 47 | } |
46 | 48 |
|
47 | 49 | @Override |
48 | 50 | public void handleUpdate(String namespace, Document selector, Document query, List<Object> modifiedIds) { |
49 | 51 | if (isOplogCollection(namespace)) { |
50 | 52 | return; |
51 | 53 | } |
52 | | - modifiedIds.forEach(id -> |
53 | | - collection.addDocument(toOplogUpdateDocument(namespace, query, id)) |
54 | | - ); |
| 54 | + final List<Document> oplogUpdateDocuments = modifiedIds.stream() |
| 55 | + .map(id -> toOplogUpdateDocument(namespace, query, id)) |
| 56 | + .collect(Collectors.toList()); |
| 57 | + collection.addDocuments(oplogUpdateDocuments); |
55 | 58 | } |
56 | 59 |
|
57 | 60 | @Override |
58 | 61 | public void handleDelete(String namespace, Document query, List<Object> deletedIds) { |
59 | 62 | if (isOplogCollection(namespace)) { |
60 | 63 | return; |
61 | 64 | } |
62 | | - deletedIds.forEach(id -> |
63 | | - collection.addDocument(toOplogDeleteDocument(namespace, id)) |
64 | | - ); |
| 65 | + final List<Document> oplogDeleteDocuments = deletedIds.stream() |
| 66 | + .map(id -> toOplogDeleteDocument(namespace, id)) |
| 67 | + .collect(Collectors.toList()); |
| 68 | + collection.addDocuments(oplogDeleteDocuments); |
65 | 69 | } |
66 | 70 |
|
67 | 71 | @Override |
|
0 commit comments