lib/job.rb in trafficbroker-mandy-0.2.12 vs lib/job.rb in trafficbroker-mandy-0.2.13
- old
+ new
@@ -24,11 +24,20 @@
end
def mixin(*modules)
modules.each {|m| @modules << m}
end
+ alias_method :serialize, :mixin
+ def input_format(format)
+ @input_format = format
+ end
+
+ def output_format(format)
+ @output_format = format
+ end
+
def set(key, value)
@settings[key.to_s] = value.to_s
end
def map_tasks(count)
@@ -59,17 +68,25 @@
@modules.each {|m| @reducer_class.send(:include, m) }
@reducer_class
end
def run_map(input=STDIN, output=STDOUT, &blk)
- mapper = @mapper_class.new(input, output)
+ @mapper_class.send(:include, Mandy::IO::OutputFormatting) unless reducer_defined?
+ mapper = @mapper_class.new(input, output, @input_format, @output_format)
yield(mapper) if blk
mapper.execute
end
def run_reduce(input=STDIN, output=STDOUT, &blk)
- reducer = @reducer_class.new(input, output)
+ reducer = @reducer_class.new(input, output, @input_format, @output_format)
yield(reducer) if blk
reducer.execute
end
+
+ private
+
+ def reducer_defined?
+ @reducer_class != Mandy::Reducers::PassThroughReducer
+ end
+
end
end
\ No newline at end of file