Class: MrMongo::MapReduce

Inherits:
Object
  • Object
show all
Defined in:
lib/mr_mongo/map_reduce.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ MapReduce

Returns a new instance of MapReduce.



6
7
8
# File 'lib/mr_mongo/map_reduce.rb', line 6

def initialize(context)
  @context = context
end

Instance Attribute Details

#collectionObject

Returns the value of attribute collection.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def collection
  @collection
end

#finalizeObject

Returns the value of attribute finalize.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def finalize
  @finalize
end

#js_modeObject

Returns the value of attribute js_mode.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def js_mode
  @js_mode
end

#limitObject

Returns the value of attribute limit.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def limit
  @limit
end

#mapObject

Returns the value of attribute map.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def map
  @map
end

#outObject

Returns the value of attribute out.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def out
  @out
end

#queryObject

Returns the value of attribute query.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def query
  @query
end

#reduceObject

Returns the value of attribute reduce.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def reduce
  @reduce
end

#scopeObject

Returns the value of attribute scope.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def scope
  @scope
end

#sortObject

Returns the value of attribute sort.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def sort
  @sort
end

#verboseObject

Returns the value of attribute verbose.



3
4
5
# File 'lib/mr_mongo/map_reduce.rb', line 3

def verbose
  @verbose
end

Instance Method Details

#execObject



26
27
28
# File 'lib/mr_mongo/map_reduce.rb', line 26

def exec
  exec_with_options(to_options)
end

#exec_on_memoryObject



30
31
32
33
34
35
36
# File 'lib/mr_mongo/map_reduce.rb', line 30

def exec_on_memory
  options = to_options
  options[:out] = {inline: true}
  options[:raw] = true

  exec_with_options(options)
end

#insert_into_collection(*args) ⇒ Object Also known as: insert



38
39
40
# File 'lib/mr_mongo/map_reduce.rb', line 38

def insert_into_collection(*args)
  mongo_collection.send(:insert, *args)
end

#to_optionsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mr_mongo/map_reduce.rb', line 10

def to_options
  options = {}

  options[:query]    = @query    if defined?(@query)
  options[:sort]     = @sort     if defined?(@sort)
  options[:limit]    = @limit    if defined?(@limit)
  options[:finalize] = @finalize if defined?(@finalize)
  options[:out]      = @out      if defined?(@out)
  options[:verbose]  = @verbose  if defined?(@verbose)
  options[:scope]    = @scope    if defined?(@scope)

  options[:raw] = true if defined?(@out) and @out.is_a?(::Hash) and @out[:inline]

  options
end