Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-2742

Consider addition of empty() to mongocxx::bulk_write

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 3.11.0
    • Affects Version/s: None
    • Component/s: Bulk API
    • Completed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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.

            Assignee:
            laurel.xiang@mongodb.com Laurel Xiang
            Reporter:
            alb@neptunesystems.com Allan Bazinet
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: