module ActiveRecord::Import::AbstractAdapter::ClassMethods

def get_insert_value_sets( values, sql_size, max_bytes ) # :nodoc:

:nodoc:
def get_insert_value_sets( values, sql_size, max_bytes ) # :nodoc:
  value_sets = []          
  arr, current_arr_values_size, current_size = [], 0, 0
  values.each_with_index do |val,i|
    comma_bytes = arr.size
    sql_size_thus_far = sql_size + current_size + val.size + comma_bytes
    if NO_MAX_PACKET == max_bytes or sql_size_thus_far <= max_bytes
      current_size += val.size            
      arr << val
    else
      value_sets << arr
      arr = [ val ]
      current_size = val.size
    end
  
    # if we're on the last iteration push whatever we have in arr to value_sets
    value_sets << arr if i == (values.size-1)
  end
  [ *value_sets ]
end

def sum_sizes( *objects ) # :nodoc:

:nodoc:
probably be moved outside this class, but to where?
Returns the sum of the sizes of the passed in objects. This should
def sum_sizes( *objects ) # :nodoc:
  objects.inject( 0 ){|sum,o| sum += o.size }
end