[CXX-2742] Consider addition of empty() to mongocxx::bulk_write Created: 31/Aug/23  Updated: 09/Oct/23

Status: Backlog
Project: C++ Driver
Component/s: Bulk API
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Unknown
Reporter: Allan Bazinet Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Improved Bulk Write API

 Description   

The mongocxx::bulk_write class is at present write-only; one can only append() to it.

Execution of an empty bulk_write is illegal and will result in an exception.

It would be convenient if this class were to expose a bool empty() const function, or, alternately, an explicit boolean conversion operator, by which to determine that it's valid or invalid for execution.

Commonly, when dealing with bulk writes, one is attempting to collate writes for performance, and execution of collated writes by a background thread is a reasonable implementation choice. In that our purported background thread presumably has no direct knowledge of the origin of the bulk_write operations it's being handed, addition of this support to bulk_write would simplify such implementations in that the thread could validate the bulk_write prior to calling execute().

Absent this support, one tends to build up a lot of scaffolding to avoid empty bulk_write operations in a generic context such as the one described.



 Comments   
Comment by Rishabh Bisht [ 12/Sep/23 ]

Thank you, Allan. This sounds like a good improvement. We will consider this ticket for our upcoming quarterly plan. 

Comment by PM Bot [ 31/Aug/23 ]

Hi alb@neptunesystems.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 22:06:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.