Class: MapBase

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

Overview

Base class for map

Map Stage Creates an object to hold input lines after they have been parsed and separated into fields. Reads input and feeds to process method, then collects output.

Direct Known Subclasses

CopyMap, SelectMap

Instance Attribute Summary

Attributes inherited from Stage

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

Instance Method Summary collapse

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 Stage

Instance Method Details

#process(input, output) ⇒ Object

Called for each record.



120
121
122
# File 'lib/mrtoolkit.rb', line 120

def process(input, output)
  nil
end

#process_begin(dummy, output) ⇒ Object

Called at the beginning of map. No input.



116
117
118
# File 'lib/mrtoolkit.rb', line 116

def process_begin(dummy, output)
  nil
end

#process_end(dummy, output) ⇒ Object

Called at the end of map.



124
125
126
# File 'lib/mrtoolkit.rb', line 124

def process_end(dummy, output)
  nil
end

#run(in_fd, out_fd) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/mrtoolkit.rb', line 128

def run(in_fd, out_fd)
  @out_fd = out_fd
  process_step(:process_begin, nil)
  input = nil
  in_fd.each_line do |line|
    @raw_input = line
    input = new_input(line)
    process_step(:process, input)
  end
  process_step(:process_end, nil)
end