[CSHARP-797] Support Bulk Write Operations Created: 12/Aug/13  Updated: 27/May/22  Resolved: 24/Feb/14

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.9

Type: New Feature Priority: Major - P3
Reporter: Craig Wilson Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-9038 New write operation method for insert... Closed
is depended on by DRIVERS-97 New Write command API & New fluent bu... Closed
Server Compat: 2.5

 Description   

Server 2.6 will be adding new bulk write operations for insert, update, and remove.



 Comments   
Comment by Githook User [ 24/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Change unit tests affected by server version 2.6.0-rc2.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/e4887065ab12d6902b22d88ab8e7031a542a14d2

Comment by Githook User [ 13/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Modify unit tests to check WriteConcernResult thoroughly.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/5adcbb4d481d42a7f81c778940d1d3b71df144f1

Comment by Githook User [ 12/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Add unit test for wtimeout and duplicate key that runs when connected to a replica set.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/674a5a0f773afade47d7caeb0695177ebdf779fd

Comment by Githook User [ 11/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Always drop the collection at the beginning of the test. Removed some unused temporary variables.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/0df8433eeef0e306d8d0ecd6ed29153d0dff4566

Comment by Githook User [ 11/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: In BulkWriteOperationTests instead of using RequestStart assume that the cluster is homogenous and that whatever features the primary supports are also supported by all other members.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/d97ab3762d5f5723f7922e56fef65fc1770c2336

Comment by Githook User [ 11/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Add unit test for

{ j : 1 }

when server is run with --nojournal.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/4b385b20162888ae051d7d60f7154587a5a2721c

Comment by Githook User [ 11/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Add unit test for w > 1 against standalone server.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/c3ff21e8bd9cab3d49aeb115c04b5e2075042422

Comment by Githook User [ 11/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Add more unit tests.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/dc5294c36c85a9aa44d401ec1a9f35b510dde152

Comment by Githook User [ 11/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Changes in response to code review comments and getting tests to pass against server 2.4.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/e69dd07b2f571872325977b69cfc954863acfbe5

Comment by Githook User [ 11/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: More unit tests.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/9f8d37e64774274ed44e48cea2e2b8f435ecf8be

Comment by Githook User [ 11/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Strengthen unit tests (work in progress).
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/d3f89f1ee5e89f2c9e7fd189a2fadbf90ef57c35

Comment by Githook User [ 05/Mar/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Make BulkWrite method internal

In 1.9.0-rc0 you had the choice of either using the BulkWrite method of MongoCollection to execute a bulk write operation, or you could choose the more verbose fluent bulk API if you wished.

In 1.9.0-rc1 we are making the BulkWrite method internal and requiring that you use the fluent bulk API instead.

To illustrate the difference between the two approaches, imagine you have an array of ids of documents you want to delete:

var ids = new BsonValue[]

{ 1, 2, 3 }

;

Using the BulkWrite method you could use LINQ to transform the list of ids into a list of delete requests and pass them to the BulkWrite method:

collection.BulkWrite(new BulkWriteArgs

{ Requests = ids.Select(id => (WriteRequest)new DeleteRequest(Query.EQ("_id", id))) }

);

Using the fluent bulk API you need to create an intermediate builder object and use it in a foreach loop to build up the multiple delete requests, and then call Execute on the intermediate builder object:

var bulk = collection.InitializeOrderedBulkOperation();
foreach (var id in ids)

{ bulk.Find(Query.EQ("_id", id)).RemoveOne(); }

bulk.Execute();

This change was made to make the .NET driver consistent with other drivers, where the fluent bulk API is the only way to create and execute batch writes.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/445bfc7dcb203047455e3fddea1dcc94dcd8b3f7

Comment by Githook User [ 27/Feb/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Prohibit Find and Insert on a bulk write operation after Execute.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/705d0c8c924777b03527babed859734c1550ba98

Comment by Githook User [ 25/Feb/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Throw an exception if a bulk operation is empty or Execute is called more than once.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/f08307b1602adfb3e355836f3e5b83a3a0fbe239

Comment by Githook User [ 21/Feb/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Changed representation of empty Requests to Enumerable.Empty<WriteRequest>.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/756f9fa37faad0ce9592ea101b5ace3cd30affe9

Comment by Githook User [ 21/Feb/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Add Requests to BulkWriteArgs.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/ead7f11ff3aefd440f52111b6c6b5181d57b152a

Comment by Githook User [ 20/Feb/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Don't allow null as the WriteConcern passed to the Execute method.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/2c5cc364c189f032ed6ed90881461cfb2e303016

Comment by Wesley McClure [ 20/Feb/14 ]

What about an overload of Execute that doesn't take a WriteConcern instead of passing null if we want to inherit from the collection settings? Passing null seems potentially confusing.

https://github.com/mongodb/mongo-csharp-driver/pull/173

Also, I added an idea of exposing BulkWriteArgs to consumers too.

Comment by Githook User [ 18/Feb/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Allow inserting batches of zero documents. Servers earlier than 2.6 will return a server side error.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/8ae12a48219431568071c0f40a5940228b79e934

Comment by Githook User [ 18/Feb/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Renamed UpdatedCount to MatchedCount.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/4660b43dc540effa605e34c35df18a60847cbc6a

Comment by Githook User [ 17/Jan/14 ]

Author:

{u'username': u'rstam', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-797: Support new write commands.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/2c3125713b196586ce92149b81e2a4ea4229b092

Generated at Wed Feb 07 21:37:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.