Class: Mongo::BulkWrite::ResultCombiner Private

Inherits:
Object
  • Object
show all
Defined in:
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.

Since:

  • 2.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResultCombiner

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.

Examples:

Create the result combiner.

ResultCombiner.new

Since:

  • 2.1.0



39
40
41
42
# File 'lib/mongo/bulk_write/result_combiner.rb', line 39

def initialize
  @results = {}
  @count = 0
end

Instance Attribute Details

#countInteger (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 count of documents in the entire batch.

Returns:

  • (Integer)

    count The count of documents in the entire batch.

Since:

  • 2.1.0



26
27
28
# File 'lib/mongo/bulk_write/result_combiner.rb', line 26

def count
  @count
end

#resultsHash (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.

Returns:

  • (Hash)

    results The results hash.

Since:

  • 2.1.0



29
30
31
# File 'lib/mongo/bulk_write/result_combiner.rb', line 29

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.

Combines a result into the overall results.

Examples:

Combine the result.

combiner.combine!(result, count)

Parameters:

  • result (Operation::Result)

    The result to combine.

  • count (Integer)

    The count of requests in the batch.

Since:

  • 2.1.0



55
56
57
58
59
60
# File 'lib/mongo/bulk_write/result_combiner.rb', line 55

def combine!(result, count)
  combine_counts!(result)
  combine_ids!(result)
  combine_errors!(result)
  @count += count
end

#resultBulkWrite::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.

Examples:

Get the final result.

combinator.result

Returns:

Since:

  • 2.1.0



72
73
74
# File 'lib/mongo/bulk_write/result_combiner.rb', line 72

def result
  BulkWrite::Result.new(results).validate!
end