1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
6 # NOTE: Migration 20190322174136_add_file_info_to_collection.rb relies on this function.
10 # Correctly groups pdhs to use for batch database updates. Helps avoid
11 # updating too many database rows in a single transaction.
12 def self.group_pdhs_for_multiple_transactions(distinct_ordered_pdhs, distinct_pdh_count, batch_size_max, log_prefix)
21 distinct_ordered_pdhs.call(last_pdh) do |pdh|
24 manifest_size = pdh.split('+')[1].to_i
25 if batch_size > 0 && batch_size + manifest_size > batch_size_max
27 done += batch_pdhs.size
28 Rails.logger.info(log_prefix + ": #{done}/#{distinct_pdh_count}")
32 batch_pdhs[pdh] = true
33 batch_size += manifest_size
37 Rails.logger.info(log_prefix + ": finished")