Class: Skynet::Partitioners::RecombineAndSplit

Inherits:
Skynet::Partitioners show all
Defined in:
lib/skynet/skynet_partitioners.rb

Class Method Summary collapse

Methods included from SkynetDebugger

#args_pp, #debug, #debug_header, #error, #fatal, included, #info, #log, #printlog, #stderr, #stdout, #warn

Class Method Details

.reduce_partition(post_map_data, new_partitions) ⇒ Object

Tries to be smart about what kind of data its getting, whether array of arrays or array of arrays of arrays.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/skynet/skynet_partitioners.rb', line 52

def self.reduce_partition(post_map_data,new_partitions)
  return post_map_data unless post_map_data.is_a?(Array) and (not post_map_data.empty?) and post_map_data.first.is_a?(Array)
  ### Why did I do this?  It breaks badly.
  # if not post_map_data.first.first.is_a?(Array)
  #   partitioned_data = post_map_data.flatten
  # else
    partitioned_data = post_map_data.inject(Array.new) do |data,part| 
      data += part
    end    
  # end    
  partitioned_data = Skynet::Partitioners::SimplePartitionData.reduce_partition(partitioned_data, new_partitions)
  debug "POST PARTITIONED DATA_SIZE", partitioned_data.size
  debug "POST PARTITIONED DATA", partitioned_data
  partitioned_data
end