Class: MinReduce

Inherits:
MaxReduce show all
Defined in:
lib/mrtoolkit.rb

Overview

Min given fields

Instance Attribute Summary

Attributes inherited from Stage

#errors, #in_fields, #in_sep, #out_fields, #out_sep

Instance Method Summary collapse

Methods inherited from MaxReduce

#compare, #declare, #initialize, #process_begin, #process_end, #sort_pool

Methods inherited from ReduceBase

#process_begin, #process_each, #process_end, #process_end_internal, #process_init, #process_internal, #process_term, #run

Methods inherited from Stage

#catch_errors, #copy_struct, #declare, #emit, #emit_separator, #field, #field_separator, #initialize, #new_input, #new_output, #prepare, #process_step, #write_out

Constructor Details

This class inherits a constructor from MaxReduce

Instance Method Details

#process(input, output) ⇒ Object



677
678
679
680
681
682
683
684
685
686
# File 'lib/mrtoolkit.rb', line 677

def process(input, output)
  if @pool.size < @m
    @pool << [input.key, input.value]
    sort_pool
  elsif input.value.to_i < @pool[-1][1].to_i
    @pool[-1] = [input.key, input.value]
    sort_pool
  end  
  nil
end