Class: Mongo::BulkWrite::ResultCombiner Private
- Inherits:
-
Object
- Object
- Mongo::BulkWrite::ResultCombiner
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/bulk_write/result_combiner.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Combines bulk write results together.
Instance Attribute Summary collapse
-
#count ⇒ Integer
readonly
private
Count The number of documents in the entire batch.
-
#results ⇒ Hash
readonly
private
Results The results hash.
Instance Method Summary collapse
-
#combine!(result, count) ⇒ Object
private
Adds a result to the overall results.
-
#initialize ⇒ ResultCombiner
constructor
private
Create the new result combiner.
-
#result ⇒ BulkWrite::Result
private
Get the final result.
Constructor Details
#initialize ⇒ ResultCombiner
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create the new result combiner.
42 43 44 45 |
# File 'build/ruby-driver-v2.19/lib/mongo/bulk_write/result_combiner.rb', line 42 def initialize @results = {} @count = 0 end |
Instance Attribute Details
#count ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns count The number of documents in the entire batch.
29 30 31 |
# File 'build/ruby-driver-v2.19/lib/mongo/bulk_write/result_combiner.rb', line 29 def count @count end |
#results ⇒ Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns results The results hash.
32 33 34 |
# File 'build/ruby-driver-v2.19/lib/mongo/bulk_write/result_combiner.rb', line 32 def results @results end |
Instance Method Details
#combine!(result, count) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds a result to the overall results.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'build/ruby-driver-v2.19/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 |
#result ⇒ BulkWrite::Result
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get the final result.
83 84 85 |
# File 'build/ruby-driver-v2.19/lib/mongo/bulk_write/result_combiner.rb', line 83 def result BulkWrite::Result.new(results, @acknowledged).validate! end |