lib/riak/map_reduce.rb in ripple-0.5.1 vs lib/riak/map_reduce.rb in ripple-0.6.0

- old
+ new

@@ -122,13 +122,21 @@ walk_spec = WalkSpec.normalize(params.shift || walk_spec_options).first @query << Phase.new({:type => :link, :function => walk_spec}.merge(options)) self end + # Sets the timeout for the map-reduce job. + # @param [Fixnum] value the job timeout, in milliseconds + def timeout(value) + @timeout = value + end + # Convert the job to JSON for submission over the HTTP interface. # @return [String] the JSON representation def to_json(options={}) - ActiveSupport::JSON.encode({"inputs" => inputs, "query" => query.map(&:as_json)}, options) + hash = {"inputs" => inputs, "query" => query.map(&:as_json)} + hash['timeout'] = @timeout.to_i if @timeout + ActiveSupport::JSON.encode(hash, options) end # Executes this map-reduce job. # @return [Array<Array>] similar to link-walking, each element is an array of results from a phase where "keep" is true. If there is only one "keep" phase, only the results from that phase will be returned. def run