lib/mongo/bulk_write.rb
# Execute the bulk write operation.
#
# @example Execute the bulk write.
#   bulk_write.execute
#
# @return [ Mongo::BulkWrite::Result ] The result.
#
# @since 2.1.0
Execute the bulk write operation.
Execute the bulk write operation .
def execute
      operation_id = Monitoring.next_operation_id
      result_combiner = ResultCombiner.new
      operations = op_combiner.combine
      client.send(:with_session, @options) do |session|
        context = Operation::Context.new(client: client, session: session)
        operations.each do |operation|
          if single_statement?(operation)
            write_concern = write_concern(session)
            write_with_retry(session, write_concern) do |server, txn_num|
              server.with_connection(service_id: context.service_id) do |connection|
                execute_operation(
                  operation.keys.first,
                  operation.values.flatten,
                  connection,
                  context,
                  operation_id,
                  result_combiner,
                  session,
                  txn_num)
              end
            end
          else
            nro_write_with_retry(session, write_concern) do |server|
              server.with_connection(service_id: context.service_id) do |connection|
                execute_operation(
                  operation.keys.first,
                  operation.values.flatten,
                  connection,
                  context,
                  operation_id,
                  result_combiner,
                  session)
              end
            end
          end
        end
      end
      result_combiner.result
    end
def execute operation_id = Monitoring . next_operation_id result_combiner = ResultCombiner . new operations = op_combiner . combine client . send ( :with_session , @options ) do | session | context = Operation :: Context . new ( client : client , session : session ) operations . each do | operation | if single_statement? ( operation ) write_concern = write_concern ( session ) write_with_retry ( session , write_concern ) do | server , txn_num | server . with_connection ( service_id : context . service_id ) do | connection | execute_operation ( operation . keys . first , operation . values . flatten , connection , context , operation_id , result_combiner , session , txn_num ) end end else nro_write_with_retry ( session , write_concern ) do | server | server . with_connection ( service_id : context . service_id ) do | connection | execute_operation ( operation . keys . first , operation . values . flatten , connection , context , operation_id , result_combiner , session ) end end end end end result_combiner . result end
Execute the bulk write operation.
Execute the bulk write operation .
None
 Mongo::BulkWrite::Result 
example
Execute the bulk write. bulk_write.execute
Execute the bulk write . bulk_write . execute
since
None