class Riak::MapReduce::FilterBuilder

Builds key-filter lists for MapReduce inputs in a DSL-like fashion.

Constants

FILTERS

Known filters available in riak_kv_mapred_filters, mapped to their arities. These are turned into instance methods. Example:

FilterBuilder.new do
  string_to_int
  less_than 50
end
LOGICAL_OPERATIONS

Available logical operations for joining filter chains. These are turned into instance methods with leading underscores, with aliases to uppercase versions. Example:

FilterBuilder.new do
  string_to_int
  AND do
    greater_than_eq 50
    neq 100
  end
end

Public Class Methods

new(&block) click to toggle source

Creates a new FilterBuilder. Pass a block that will be instance_eval’ed to construct the sequence of filters.

# File lib/riak/map_reduce/filter_builder.rb, line 85
def initialize(&block)
  @filters = []
  instance_eval(&block) if block_given?
end

Public Instance Methods

seq(&block)
Alias for: sequence
sequence(&block) click to toggle source

Wraps multi-step filters for use inside logical operations. Does not correspond to an actual filter.

# File lib/riak/map_reduce/filter_builder.rb, line 92
def sequence(&block)
  @filters << self.class.new(&block).to_a
end
Also aliased as: seq
to_a() click to toggle source

@return A list of filters for handing to the MapReduce inputs.

# File lib/riak/map_reduce/filter_builder.rb, line 98
def to_a
  @filters
end