Class: Mandy::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/mandy/task.rb

Direct Known Subclasses

Mappers::Base, Reducers::Base

Constant Summary collapse

KEY_VALUE_SEPERATOR =
"\t"
NUMERIC_PADDING =
16
DEFAULT_COUNTER_GROUP =
'Mandy Counters'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input = STDIN, output = STDOUT, input_format = nil, output_format = nil) ⇒ Task

Returns a new instance of Task.



9
10
11
12
# File 'lib/mandy/task.rb', line 9

def initialize(input=STDIN, output=STDOUT, input_format = nil, output_format = nil)
  @input, @output = input, output
  @input_format, @output_format = input_format, output_format
end

Instance Attribute Details

#input_formatObject (readonly)

Returns the value of attribute input_format.



7
8
9
# File 'lib/mandy/task.rb', line 7

def input_format
  @input_format
end

#output_formatObject (readonly)

Returns the value of attribute output_format.



7
8
9
# File 'lib/mandy/task.rb', line 7

def output_format
  @output_format
end

Instance Method Details

#emit(key, value = nil) ⇒ Object



14
15
16
17
# File 'lib/mandy/task.rb', line 14

def emit(key, value=nil)
  data = value.nil? ? key.to_s : "#{output_serialize_key(key)}\t#{output_serialize_value(value)}"
  @output.puts data.chomp
end

#get(store, key) ⇒ Object



19
20
21
# File 'lib/mandy/task.rb', line 19

def get(store, key)
  Mandy.stores[store].get(key)
end

#put(store, key, values) ⇒ Object



23
24
25
# File 'lib/mandy/task.rb', line 23

def put(store, key, values)
  Mandy.stores[store].put(key, values)
end