mongodb/mongo-ruby-driver — pull request #169 by estolfo (2013-03-03 21:51:23+00:00)
Title: RUBY-533 Split bulk inserts into many messages

This pull request splits up a bulk insert into many messages.

collection.rb notes: There is no longer an error raised if the max message size is exceded because the documents will be split up into multi messages. You'd never have a case of trying to send a message that is too large. The only edge case I could think of was when a single document is larger than the max message size but this would never happen because the max message size is always greater than the max document size.

collect_on_error is a flag that fails silently on serialization errors and collects the documents into a list that haven't been serialized. I made the decision to-- in the case that collect_on_error is set with only one document-- raise the single error instead of inserting nothing and returning that document as the error document. I'm not confident this is the best way to handle the scenario. Maybe we should raise an error if collect_on_error is set with a single document?

collection_test.rb notes: I added some tests for splitting up a bulk insert into multiple messages and removed a test that added huge documents onto a message and then expected it to raise an error saying the message was too large. As I mentioned above, this test no longer fails because the documents were split up into multi messages.