Skip to content

Commit 9d37fac

Browse files
committed
feedback initial pass
1 parent 161ffec commit 9d37fac

File tree

2 files changed

+72
-60
lines changed

2 files changed

+72
-60
lines changed

source/fundamentals/crud/write-operations/bulk.txt

Lines changed: 63 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ Overview
1616
In this guide, you can learn how to use bulk operations in the
1717
MongoDB Java Driver.
1818

19-
.. note:: Improved Bulk Write Commands
19+
.. note:: Client Bulk Write Method
2020

21-
The first half of this guide focuses on the ``MongoCollection.bulkWrite()``
22-
method. In {+mdb-server+} version 8.0 and {+driver-short+} version 5.3 and later,
23-
you can use an improved ``MongoClient.bulkWrite()`` method which can write
24-
to multiple databases and collections at once. See the :ref:`improved-bulk-write`
25-
section below to learn how to use the new method.
21+
This guide primarily focuses on the ``MongoCollection.bulkWrite()``
22+
method, which allows you to perform bulk operations on a collection.
23+
When connecting to a deployment running {+mdb-server+} 8.0 or later,
24+
you can use the ``MongoClient.bulkWrite()`` method to write
25+
to multiple databases and collections in the same call. See the
26+
:ref:`java-sync-client-bulk-write` section below to learn how to use the
27+
``MongoClient.bulkWrite()`` method.
2628

2729
To perform a create, replace, update, or delete operation,
2830
use its corresponding method. For example, to insert one document,
@@ -108,7 +110,7 @@ describing people:
108110
For more information about the methods and classes mentioned in this section,
109111
see the `InsertOneModel
110112
<{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/InsertOneModel.html>`__
111-
API Documentation.
113+
API documentation.
112114

113115
Replace Operation
114116
~~~~~~~~~~~~~~~~~
@@ -140,7 +142,7 @@ contains an added ``location`` field:
140142
For more information about the methods and classes mentioned in this section,
141143
see the following resources:
142144

143-
- `ReplaceOneModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/ReplaceOneModel.html>`__ API Documentation
145+
- `ReplaceOneModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/ReplaceOneModel.html>`__ API documentation
144146
- :manual:`Unique indexes </core/index-unique/>` Server Manual Explanation
145147

146148
Update Operation
@@ -176,8 +178,8 @@ the ``age`` field in a document where the ``_id`` is ``2``:
176178
For more information about the methods and classes mentioned in this section,
177179
see the following resources:
178180

179-
- `UpdateOneModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/UpdateOneModel.html>`__ API Documentation
180-
- `UpdateManyModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/UpdateManyModel.html>`__ API Documentation
181+
- `UpdateOneModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/UpdateOneModel.html>`__ API documentation
182+
- `UpdateManyModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/UpdateManyModel.html>`__ API documentation
181183
- :manual:`unique indexes </core/index-unique/>` Server Manual Explanation
182184

183185
Delete Operation
@@ -210,7 +212,7 @@ a document where the ``_id`` is ``1``:
210212
:end-before: end deleteDocumentsExample
211213

212214
For more information about the methods and classes mentioned in this section,
213-
see the following API Documentation:
215+
see the following API documentation:
214216

215217
- `DeleteOneModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/DeleteOneModel.html>`__
216218
- `DeleteManyModel <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/DeleteManyModel.html>`__
@@ -296,45 +298,48 @@ operations to execute in any order:
296298
{ "_id": 6, "name": "Zaynab Omar", "age": 37 }
297299

298300
For more information about the methods and classes mentioned in this section,
299-
see the following API Documentation:
301+
see the following API documentation:
300302

301303
- `BulkWriteOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/BulkWriteOptions.html>`__
302304
- `ordered() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/BulkWriteOptions.html#ordered(boolean)>`__
303305

304-
.. _improved-bulk-write:
306+
.. _java-sync-client-bulk-write:
305307

306-
Improved Bulk Write Command
307-
---------------------------
308+
Client Bulk Write Method
309+
------------------------
308310

309-
Starting with {+mdb-server+} version 8.0 and {+driver-short+} version 5.3, there
310-
is an improved bulk write method, ``MongoClient.bulkWrite()``, that writes to
311-
different databases and collections in the same cluster.
311+
When connecting to a deployment running {+mdb-server+} 8.0 or later,
312+
you can use the ``MongoClient.bulkWrite()`` method to write
313+
to multiple databases and collections in the same cluster.
312314

313-
In the previous examples on this page, the ``bulkWrite()`` method takes a list
314-
of ``WriteModel`` documents in which the specified subclass of ``WriteModel``
315-
represents the corresponding write operation. For example, ``InsertOneModel``
316-
represents inserting one document.
315+
In the examples in preceding sections of this page, the ``MongoCollection.bulkWrite()`` method
316+
takes a list of ``WriteModel`` documents in which the specified subclass of
317+
``WriteModel`` represents the corresponding write operation. For example, an
318+
instance of ``InsertOneModel`` represents an operation to insert one document.
317319

318-
Similarly, the new ``bulkWrite()`` method takes a
319-
list of ``ClientNamespacedWriteModel`` objects to represent the write operation.
320+
.. TODO - not necessarily instances
321+
322+
Similarly, the ``MongoClient.bulkWrite()`` method takes a
323+
list of ``ClientNamespacedWriteModel`` instances to represent different write operations.
320324
However, you do not need to specify the subclass that represents the corresponding
321325
write operation. Instead, the ``ClientNamespacedWriteModel`` object contains different
322326
methods to represent different write operations, such as ``insertOne()`` or
323327
``updateOne()``.
324328

325329
These methods take a ``MongoNamespace`` object that defines which
326-
database and collection to write to, and a ``Document`` object that defines the
327-
document information. Some methods, such as ``updateOne()`` and ``replaceOne()``,
328-
also take a ``Filters`` object that defines the filter for the operation.
330+
database and collection to write to, and a ``Document`` object that defines
331+
information about the write operation. Some methods, such as ``updateOne()`` and
332+
``replaceOne()``, also take a ``Filters`` object that defines the filter for the operation.
329333

330-
The following sections describe how to use the new ``bulkWrite()`` method.
334+
The following sections describe how to use the client ``bulkWrite()`` method.
331335

332336
Insert Example
333337
~~~~~~~~~~~~~~
334338

335-
The following example shows how to use the new ``bulkWrite()`` method to insert
336-
two documents. One document is inserted into the ``people`` collection in our
337-
database. The other document is inserted into a collection called ``things``.
339+
This following example shows how to use the ``bulkWrite()`` method to insert
340+
two documents. One document is inserted into the ``people`` collection in a
341+
database named ``db``. The other document is inserted into a collection called ``things``
342+
in the ``db`` database.
338343
We use the ``MongoNamespace`` object to define the database and collection we
339344
want each write operation to be applied to.
340345

@@ -348,18 +353,13 @@ want each write operation to be applied to.
348353
ClientNamespacedWriteModel.insertOne(thingsNamespace, new Document("object", "washing machine"))
349354
));
350355

351-
After this example is executed, the ``people`` collection holds a
352-
``{ "name": "Julia Smith" }`` document and the ``things`` collection holds
353-
a ``{ "object": "washing machine" }`` document.
354-
355356
.. TODO: link documentation
356357

357358
Replace Example
358359
~~~~~~~~~~~~~~~
359360

360-
The following example shows how to use the ``bulkWrite()`` method to replace an
361-
existing document in the ``people`` collection and an existing document in the
362-
``things`` collection.
361+
The following example shows how to use the ``bulkWrite()`` method to replace
362+
existing documents in the ``people`` and ``things`` collections.
363363

364364
.. code-block:: java
365365

@@ -379,28 +379,32 @@ existing document in the ``people`` collection and an existing document in the
379379
)
380380
));
381381

382-
After this example is executed, the document in the ``people`` collection in
383-
which the ``_id`` field has the value of ``1`` has been replaced with a new
384-
``{ "name": "Maximus Farquaad" }`` document. Also, the document
385-
in the ``things`` collection in which the ``_id`` field has the value of ``1``
386-
has been replaced with a ``{ "object": "potato" }`` document.
382+
After this example runs successfully, the document in the ``people`` collection in
383+
which the ``_id`` field has the value of ``1`` is replaced with a new
384+
document. The document in the ``things`` collection in which the
385+
``_id`` field has the value of ``1`` is replaced with a new document.
386+
387+
.. _java-sync-client-bulk-write-options:
387388

388389
Bulk Write Options
389390
~~~~~~~~~~~~~~~~~~
390391

391-
Similarly to the :ref:`orderOfExecution` section above, you can use the
392-
``ClientBulkWriteOptions`` object to execute the new ``bulkWrite()`` method
393-
with options.
392+
.. TODO: reword this
393+
394+
You can use the ``ClientBulkWriteOptions`` object to execute the ``bulkWrite()``
395+
method with options.
394396

395397
Order of Execution Example
396398
``````````````````````````
399+
By default, the write operations execute in the order that you specify them. However,
400+
you can pass ``false`` to the ``ordered()`` method on the ``ClientBulkWriteOptions``
401+
object to perform write operations in an unordered way. When using the unordered
402+
option, an error-producing operation will not block execution of other bulk
403+
write operations.
397404

398-
As described in the previous Order of Execution section, by default the write
399-
operations execute in the order they're specified. However, we can pass
400-
``false`` to the ``ordered()`` method on the ``ClientBulkWriteOptions`` object
401-
to execute write operations in any order.
405+
.. TODO: the object itself is not necessarily being created
402406

403-
The following code shows how to use the ``ordered()`` method on the
407+
The following code shows how to set the ``ordered()`` method on the
404408
``ClientBulkWriteOptions`` object.
405409

406410
.. code-block:: java
@@ -409,11 +413,13 @@ The following code shows how to use the ``ordered()`` method on the
409413

410414
ClientBulkWriteOptions options = new ClientBulkWriteOptions().ordered(false);
411415

412-
ClientBulkWriteResult result = client.bulkWrite(List<>(
413-
ClientNamespacedWriteModel.insertOne(namespace, new Document("name", "Donkey Kong")),
414-
ClientNamespacedWriteModel.insertOne(namespace, new Document("name", "Mario"))
416+
ClientBulkWriteResult result = client.bulkWrite(
417+
List<>(
418+
ClientNamespacedWriteModel.insertOne(namespace, new Document("name", "Donkey Kong")),
419+
ClientNamespacedWriteModel.insertOne(namespace, new Document("name", "Mario"))
415420
),
416-
options);
421+
options
422+
);
417423

418424
.. TODO: link documentation
419425

@@ -455,5 +461,5 @@ options for how the command is executed.
455461
.. OPEN QUESTIONS FOR ENGINEERING:
456462
.. Should I include the extraneous types like the Client...Result object?
457463
.. Should I include the different ClientNamespacedInsertModel... etc?
458-
.. Is ClientWriteModel being exposed for public use?
459-
.. Is MongoCollection.bulkWrite() being deprecated?
464+
.. Is ClientWriteModel being exposed for public use? <no>
465+
.. Is MongoCollection.bulkWrite() being deprecated? <no>

source/whats-new.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ Learn what's new in:
3535
What's New in 5.3
3636
-----------------
3737

38-
New features of the 5.3 release include:
38+
The 5.3 {+driver-short+} release introduces the following improvements, features,
39+
and fixes:
3940

40-
- A new :ref:`bulk write command <improved-bulk-write>` that can perform bulk
41-
write operations on multiple databases and collections at once.
41+
- Client bulk write API that allows you to perform write operations on multiple
42+
databases and collections at once. To learn more about this feature, see the
43+
:ref:`java-sync-client-bulk-write` section of the Bulk Operations guide.
44+
45+
- A ``ClientBulkWriteOptions`` object to specify different options for how
46+
the client bulk write API is executed. See the :ref:`java-sync-client-bulk-write-options`
47+
section of the Client Bulk Write guide.
4248

4349
.. _java-version-5.2.1:
4450

0 commit comments

Comments
 (0)