Class: Mongo::BulkWrite::ResultCombiner Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/mongo/bulk_write/result_combiner.rb |
Overview
Combines bulk write results together.
Class Method Summary
-
.new ⇒ ResultCombiner
constructor
Internal use only
Create the new result combiner.
Instance Attribute Summary
- #count ⇒ Integer readonly Internal use only
- #results ⇒ Hash readonly Internal use only
Instance Method Summary
-
#combine!(result, count)
Internal use only
Adds a result to the overall results.
-
#result ⇒ BulkWrite::Result
Internal use only
Get the final result.
- #combine_counts!(result) private Internal use only
- #combine_errors!(result) private Internal use only
- #combine_ids!(result) private Internal use only
- #combine_write_concern_errors!(result) private Internal use only
- #combine_write_errors!(result) private Internal use only
Instance Attribute Details
#count ⇒ Integer
(readonly)
# File 'lib/mongo/bulk_write/result_combiner.rb', line 29
attr_reader :count
#results ⇒ Hash
(readonly)
# File 'lib/mongo/bulk_write/result_combiner.rb', line 32
attr_reader :results
Instance Method Details
#combine!(result, count)
Adds a result to the overall results.
# File 'lib/mongo/bulk_write/result_combiner.rb', line 58
def combine!(result, count) # Errors can be communicated by the server in a variety of fields: # writeError, writeErrors, writeConcernError, writeConcernErrors. # Currently only errors given in writeConcernErrors will cause # counts not to be added, because this behavior is covered by the # retryable writes tests. It is possible that some or all of the # other errors should also be excluded when combining counts and # ids, and it is also possible that only a subset of these error # fields is actually possible in the context of bulk writes. unless result.write_concern_error? combine_counts!(result) combine_ids!(result) end combine_errors!(result) @count += count @acknowledged = result.acknowledged? end
#combine_counts!(result) (private)
#combine_errors!(result) (private)
# File 'lib/mongo/bulk_write/result_combiner.rb', line 108
def combine_errors!(result) combine_write_errors!(result) combine_write_concern_errors!(result) end
#combine_ids!(result) (private)
# File 'lib/mongo/bulk_write/result_combiner.rb', line 97
def combine_ids!(result) if result.respond_to?(Result::INSERTED_IDS) results[Result::INSERTED_IDS] = (results[Result::INSERTED_IDS] || []) + result.inserted_ids end if result.respond_to?(Result::UPSERTED) results[Result::UPSERTED_IDS] = (results[Result::UPSERTED_IDS] || []) + result.upserted.map{ |doc| doc['_id'] } end end
#combine_write_concern_errors!(result) (private)
#combine_write_errors!(result) (private)
#result ⇒ BulkWrite::Result
Get the final result.