17
17
18
18
import java .util .List ;
19
19
20
- import org .springframework .data .mongodb .BulkOperationException ;
21
20
import org .springframework .data .mongodb .core .query .Query ;
22
21
import org .springframework .data .mongodb .core .query .Update ;
23
- import org .springframework .data .mongodb . util .Tuple ;
22
+ import org .springframework .data .util .Tuple ;
24
23
25
24
import com .mongodb .BulkWriteResult ;
26
- import com .mongodb .WriteConcern ;
27
25
28
26
/**
29
- * Bulk operations for insert/update/remove actions on a collection.
30
- * <p/>
31
- * These bulks operation are available since MongoDB 2.6 and make use of low level bulk commands on the protocol level.
32
- * <p/>
33
- * This interface defines a fluent API add multiple single operations or list of similar operations in sequence.
27
+ * Bulk operations for insert/update/remove actions on a collection. These bulks operation are available since MongoDB
28
+ * 2.6 and make use of low level bulk commands on the protocol level. This interface defines a fluent API to add
29
+ * multiple single operations or list of similar operations in sequence which can then eventually be executed by calling
30
+ * {@link #execute()}.
34
31
*
35
32
* @author Tobias Trelle
33
+ * @author Oliver Gierke
34
+ * @since 1.9
36
35
*/
37
36
public interface BulkOperations {
38
37
39
- /** Mode for bulk operation. */
38
+ /**
39
+ * Mode for bulk operation.
40
+ **/
40
41
public enum BulkMode {
41
42
42
43
/** Perform bulk operations in sequence. The first error will cancel processing. */
@@ -45,44 +46,37 @@ public enum BulkMode {
45
46
/** Perform bulk operations in parallel. Processing will continue on errors. */
46
47
UNORDERED
47
48
};
49
+
48
50
/**
49
51
* Add a single insert to the bulk operation.
50
52
*
51
- * @param documents List of documents to insert.
52
- *
53
- * @return The bulk operation.
54
- *
55
- * @throws BulkOperationException if an error occured during bulk processing.
53
+ * @param documents the document to insert, must not be {@literal null}.
54
+ * @return the current {@link BulkOperations} instance with the insert added, will never be {@literal null}.
56
55
*/
57
- BulkOperations insert (Object documents );
58
-
56
+ BulkOperations insert (Object documents );
57
+
59
58
/**
60
59
* Add a list of inserts to the bulk operation.
61
60
*
62
- * @param documents List of documents to insert.
63
- *
64
- * @return The bulk operation.
65
- *
66
- * @throws BulkOperationException if an error occured during bulk processing.
61
+ * @param documents List of documents to insert, must not be {@literal null}.
62
+ * @return the current {@link BulkOperations} instance with the insert added, will never be {@literal null}.
67
63
*/
68
64
BulkOperations insert (List <? extends Object > documents );
69
65
70
66
/**
71
- * Add a single update to the bulk operation. For the update request, only the first matching document is updated.
67
+ * Add a single update to the bulk operation. For the update request, only the first matching document is updated.
72
68
*
73
- * @param query Update criteria.
74
- * @param update Update operation to perform.
75
- *
76
- * @return The bulk operation.
69
+ * @param query update criteria, must not be {@literal null}.
70
+ * @param update {@link Update} operation to perform, must not be {@literal null}.
71
+ * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
77
72
*/
78
- BulkOperations updateOne (Query query , Update update );
79
-
73
+ BulkOperations updateOne (Query query , Update update );
74
+
80
75
/**
81
- * Add a list of updates to the bulk operation. For each update request, only the first matching document is updated.
76
+ * Add a list of updates to the bulk operation. For each update request, only the first matching document is updated.
82
77
*
83
78
* @param updates Update operations to perform.
84
- *
85
- * @return The bulk operation.
79
+ * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
86
80
*/
87
81
BulkOperations updateOne (List <Tuple <Query , Update >> updates );
88
82
@@ -91,17 +85,16 @@ public enum BulkMode {
91
85
*
92
86
* @param query Update criteria.
93
87
* @param update Update operation to perform.
94
- *
95
- * @return The bulk operation.
88
+ * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
96
89
*/
97
90
BulkOperations updateMulti (Query query , Update update );
98
-
91
+
99
92
/**
100
93
* Add a list of updates to the bulk operation. For each update request, all matching documents are updated.
101
94
*
102
95
* @param updates Update operations to perform.
103
- *
104
96
* @return The bulk operation.
97
+ * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
105
98
*/
106
99
BulkOperations updateMulti (List <Tuple <Query , Update >> updates );
107
100
@@ -111,57 +104,42 @@ public enum BulkMode {
111
104
*
112
105
* @param query Update criteria.
113
106
* @param update Update operation to perform.
114
- *
115
107
* @return The bulk operation.
108
+ * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
116
109
*/
117
- BulkOperations upsert (Query query , Update update );
118
-
110
+ BulkOperations upsert (Query query , Update update );
111
+
119
112
/**
120
- * Add a list of upserts to the bulk operation. An upsert is an update if the set of matching documents is not empty, else an
121
- * insert.
113
+ * Add a list of upserts to the bulk operation. An upsert is an update if the set of matching documents is not empty,
114
+ * else an insert.
122
115
*
123
116
* @param updates Updates/insert operations to perform.
124
- *
125
117
* @return The bulk operation.
118
+ * @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
126
119
*/
127
120
BulkOperations upsert (List <Tuple <Query , Update >> updates );
128
121
129
122
/**
130
123
* Add a single remove operation to the bulk operation.
131
124
*
132
- * @param remove operations to perform.
133
- *
134
- * @return The bulk operation.
125
+ * @param remove the {@link Query} to select the documents to be removed, must not be {@literal null}.
126
+ * @return the current {@link BulkOperations} instance with the removal added, will never be {@literal null}.
135
127
*/
136
- BulkOperations remove (Query remove );
137
-
128
+ BulkOperations remove (Query remove );
129
+
138
130
/**
139
131
* Add a list of remove operations to the bulk operation.
140
132
*
141
- * @param remove operations to perform.
142
- *
143
- * @return The bulk operation.
133
+ * @param removes the remove operations to perform, must not be {@literal null}.
134
+ * @return the current {@link BulkOperations} instance with the removal added, will never be {@literal null}.
144
135
*/
145
136
BulkOperations remove (List <Query > removes );
146
137
147
138
/**
148
139
* Execute all bulk operations using the default write concern.
149
140
*
150
141
* @return Result of the bulk operation providing counters for inserts/updates etc.
151
- *
152
- * @throws BulkOperationException if errors occur during the exection of the bulk operations.
142
+ * @throws {@link BulkOperationException} if an error occurred during bulk processing.
153
143
*/
154
- BulkWriteResult executeBulk ();
155
-
156
- /**
157
- * Execute all bulk operations using the given write concern.
158
- *
159
- * @param writeConcern Write concern to use.
160
- *
161
- * @return Result of the bulk operation providing counters for inserts/updates etc.
162
- *
163
- * @throws BulkOperationException if errors occur during the exection of the bulk operations.
164
- */
165
- BulkWriteResult executeBulk (WriteConcern writeConcern );
166
-
144
+ BulkWriteResult execute ();
167
145
}
0 commit comments