mongodb/mongo-ruby-driver — pull request #316 by gjmurakami-10gen (2013-11-21 04:13:46+00:00)
Title: Unordered bulk operations and headroom for new write-command BSON-packaging overhead

Unordered bulk operations should be executed with one batch per write-type.

Maximum sizes should be handled carefully as the new write commands have overhead from BSON packaging.
The server gives us 16K of headroom, I've defined headroom constants that divide this so that we can safely append to BSON and serialize BSON while allowing for the overhead.

Please see the specification pull request where I've documented this.

https://github.com/10gen/specifications/pull/1

In some aspects, the Ruby tests and code may be easier to understand.
Regardless, I'm happy with the overall solution, but always welcome comments, refactoring, cleanup, etc.