Skip to content

Commit

Permalink
Fixing things here and there, not like anyone is reading these messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinay Mehta authored and Abhinay Mehta committed Feb 12, 2010
1 parent f1a08fe commit b1e0246
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
9 changes: 8 additions & 1 deletion bin/jmandy-hadoop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require "rubygems"
require "jmandy"
require 'jmandy'
require 'optparse'
require 'ostruct'
require 'uri'
Expand Down Expand Up @@ -31,6 +31,12 @@ def set_env(opts_string)
end
end

def check_env
%w(JAVA_HOME JRUBY_HOME HADOOP_HOME).each do |env|
raise "#{env} not found" unless ENV[env]
end
end

file = File.expand_path(ARGV[0])
inputs = ARGV[1].split(",")
input = inputs.map {|path| "#{path}"}.join(" ")
Expand All @@ -40,6 +46,7 @@ config = absolute_path(options.config || 'cluster.xml')
puts "Packaging code for distribution..."
cmdenv = options.cmdenv
set_env(cmdenv)
check_env

at_exit do
puts
Expand Down
3 changes: 3 additions & 0 deletions examples/word_count.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
map_tasks 5
reduce_tasks 5

setup do
end

map do |key, value|
words = {}
value.split(' ').each do |word|
Expand Down
10 changes: 8 additions & 2 deletions lib/jmandy/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,17 @@ def reducer_class
end

def compile_map
@map.is_a?(Proc) ? JMandy::Mappers::Base.compile({}, &@map) : @map
args = {}
args[:setup] = @setup if @setup
args[:teardown] = @teardown if @teardown
@map.is_a?(Proc) ? JMandy::Mappers::Base.compile(args, &@map) : @map
end

def compile_reduce
@reduce.is_a?(Proc) ? JMandy::Reducers::Base.compile({}, &@reduce) : @reduce
args = {}
args[:setup] = @setup if @setup
args[:teardown] = @teardown if @teardown
@reduce.is_a?(Proc) ? JMandy::Reducers::Base.compile(args, &@reduce) : @reduce
end
end
end
10 changes: 7 additions & 3 deletions lib/jmandy/mappers/base_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ def self.compile(opts={}, &blk)
Class.new(JMandy::Mappers::Base) do
self.class_eval do
define_method(:mapper, blk) if blk
define_method(:setup, opts[:setup]) if opts[:setup]
define_method(:teardown, opts[:teardown]) if opts[:teardown]
end
end
end

def execute
setup if self.respond_to?(:setup)
mapper(@key, @value)
teardown if self.respond_to?(:teardown)
end

private

def mapper(key,value)
#nil
end
end
end
end
end
8 changes: 6 additions & 2 deletions lib/jmandy/reducers/base_reducer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ def self.compile(opts={}, &blk)
Class.new(JMandy::Reducers::Base) do
self.class_eval do
define_method(:reducer, blk) if blk
define_method(:setup, opts[:setup]) if opts[:setup]
define_method(:teardown, opts[:teardown]) if opts[:teardown]
end
end
end

def execute
setup if self.respond_to?(:setup)
reducer(@key, @values)
teardown if self.respond_to?(:teardown)
end

private

def reducer(key,values)
Expand Down

0 comments on commit b1e0246

Please sign in to comment.