Class: Riak::MapReduce::FilterBuilder
- Inherits:
-
Object
- Object
- Riak::MapReduce::FilterBuilder
- Includes:
- Util::Translation
- Defined in:
- riak-client/lib/riak/map_reduce/filter_builder.rb
Overview
Builds key-filter lists for MapReduce inputs in a DSL-like fashion.
Constant Summary
- 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
{ :int_to_string => 0, :string_to_int => 0, :float_to_string => 0, :string_to_float => 0, :to_upper => 0, :to_lower => 0, :tokenize => 2, :urldecode => 0, :greater_than => 1, :less_than => 1, :greater_than_eq => 1, :less_than_eq => 1, :between => [2,3], :matches => 1, :neq => 1, :eq => 1, :set_member => -1, :similar_to => 2, :starts_with => 1, :ends_with => 1 }
- 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 seq { greater_than_eq 50 } seq { neq 100 } end end
%w{and or not}
Instance Method Summary (collapse)
-
- (FilterBuilder) initialize(&block)
constructor
Creates a new FilterBuilder.
-
- (Object) sequence(&block)
(also: #seq)
Wraps multi-step filters for use inside logical operations.
-
- (Object) to_a
A list of filters for handing to the MapReduce inputs.
Methods included from Util::Translation
Constructor Details
- (FilterBuilder) initialize(&block)
Creates a new FilterBuilder. Pass a block that will be instance_eval’ed to construct the sequence of filters.
89 90 91 92 |
# File 'riak-client/lib/riak/map_reduce/filter_builder.rb', line 89 def initialize(&block) @filters = [] instance_eval(&block) if block_given? end |
Instance Method Details
- (Object) sequence(&block) Also known as: seq
Wraps multi-step filters for use inside logical operations. Does not correspond to an actual filter.
96 97 98 |
# File 'riak-client/lib/riak/map_reduce/filter_builder.rb', line 96 def sequence(&block) @filters << self.class.new(&block).to_a end |
- (Object) to_a
A list of filters for handing to the MapReduce inputs.
102 103 104 |
# File 'riak-client/lib/riak/map_reduce/filter_builder.rb', line 102 def to_a @filters end |