Class: AppEngine::MapReduce::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/appengine-mapreduce/job.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Job

Returns a new instance of Job.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/appengine-mapreduce/job.rb', line 25

def initialize options = {}
  @properties = {}

  %w(map reduce input_class input_kind output_kind).each do |attr_n|
    key = (attr_n.to_sym rescue attr_n) || attr_n
    self.send("#{attr_n}=", options.delete(key)) if options[key]
  end

  @properties["mapreduce.map.class"] = JRUBY_PROXY_MAPPER_CLASS

end

Instance Attribute Details

#input_classObject

Returns the value of attribute input_class.



23
24
25
# File 'lib/appengine-mapreduce/job.rb', line 23

def input_class
  @input_class
end

#input_kindObject

Returns the value of attribute input_kind.



23
24
25
# File 'lib/appengine-mapreduce/job.rb', line 23

def input_kind
  @input_kind
end

#map(&block) ⇒ Object

Returns the value of attribute map.



23
24
25
# File 'lib/appengine-mapreduce/job.rb', line 23

def map
  @map
end

#output_kindObject

Returns the value of attribute output_kind.



23
24
25
# File 'lib/appengine-mapreduce/job.rb', line 23

def output_kind
  @output_kind
end

#propertiesObject

Returns the value of attribute properties.



23
24
25
# File 'lib/appengine-mapreduce/job.rb', line 23

def properties
  @properties
end

#reduceObject

Returns the value of attribute reduce.



23
24
25
# File 'lib/appengine-mapreduce/job.rb', line 23

def reduce
  @reduce
end

Class Method Details

.create_job_for(mapper_name) ⇒ Object



77
78
79
80
81
82
83
# File 'lib/appengine-mapreduce/job.rb', line 77

def self.create_job_for mapper_name
  map = <<MAP
require 'lib/mappers/#{mapper_name.to_s}_mapper'
include #{mapper_name.to_s.camelize}Mapper
MAP
  Job.new(:map => map)
end

Instance Method Details

#runObject



37
38
39
40
41
42
43
# File 'lib/appengine-mapreduce/job.rb', line 37

def run
  queue = AppEngine::Labs::TaskQueue

  queue.add({:method => 'POST',
            :params => {'configuration' => conf_as_string},
            :url => "/mapreduce/start"})
end

#use_blobstore_input_classObject



73
74
75
# File 'lib/appengine-mapreduce/job.rb', line 73

def use_blobstore_input_class
  self.input_class = BLOBSTORE_INPUT_FORMAT
end