类:Mongoid::Contextual::MapReduce
- 继承:
-
对象
- 对象
- Mongoid::Contextual::MapReduce
- 扩展方式:
- 可转发
- 包括:
- 可枚举,命令
- 定义于:
- lib/mongoid/contextual/map_reduce.rb
Overview
表示 mapReduce数据库命令指令。
实例属性摘要
命令包含的属性
# 集合 , # 集合要查询的集合。 、 #criteria 、 #criteria 上下文的条件。
实例方法摘要折叠
-
#命令⇒ 哈希
返回命令规范的选择器。
-
# counts ⇒ 哈希
获取 map/reduce 返回的所有计数。
-
#each (&block) ⇒ 枚举器
遍历 map/reduce 中的每个文档,不包括从数据库传回的额外信息。
-
发出的数量 ⇒ 整数
获取 map/reduce 发出的文档数量。
-
# finalize (function) ⇒ MapReduce
为 map/reduce 提供 finalize JavaScript函数。
-
#initialize (collection,riteria,map,reduce) ⇒ MapReduce
构造函数
初始化新的 map/reduce 指令。
-
#输入⇒ 整数
获取输入到 map/reduce 中的文档数。
-
#检查⇒ string
获取 map/reduce 的美观string表示形式,包括条件、map、reduce、finalize 和 out 选项。
-
# js_mode ⇒ MapReduce
将 map/reduce 设置为使用 jsMode。
-
# out (位置) ⇒ MapReduce
指定 map/reduce 输出的存储位置。
-
#output ⇒ Integer
获取 map/reduce 输出的文档数。
-
#raw ⇒哈希(也:#results、#execute)
获取 map/reduce 操作的原始输出。
-
# Reduced ⇒ 整数
获取通过 map/reduce 减少的文档数。
-
#作用域(对象)→ MapReduce
将 JavaScript对象添加到 map/reduce 的全局范围。
-
# time ⇒ Float
获取 map/reduce 的执行时间。
命令中包含的方法
构造函数详情
#initialize (集合,riteria, map, reduce) ⇒ MapReduce
初始化新的 map/reduce 指令。
73 74 75 76 77 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 73 def 初始化(集合, 条件, map, 化简(reduce)) @collection = 集合 @criteria = 条件 @map_reduce = @criteria.查看.map_reduce(map, 化简(reduce)) end |
实例方法详细信息
#命令⇒哈希
返回命令规范的选择器。
217 218 219 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 217 def 命令 @map_reduce.发送(:map_reduce_spec)[:selector] end |
# counts ⇒哈希
获取 map/reduce 返回的所有计数。
20 21 22 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 20 def counts 结果[' counts '] end |
#each (&block) ⇒枚举器
遍历 map/reduce 中的每个文档,不包括从数据库传回的额外信息。
33 34 35 36 37 38 39 40 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 33 def 每(和块) validate_out! if block_given? @map_reduce.每(和块) else @map_reduce.to_enum end end |
发出的数量 ⇒整数
获取 map/reduce 发出的文档数量。
48 49 50 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 48 def 发出 counts['emit'] end |
# finalize (function) ⇒ MapReduce
为 map/reduce 提供 finalize JavaScript函数。
60 61 62 63 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 60 def finalize(function) @map_reduce = @map_reduce.finalize(function) self end |
#input ⇒ Integer
获取输入到 map/reduce 中的文档数。
85 86 87 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 85 def 输入 counts['input'] end |
#检查⇒ string
获取 map/reduce 的美观string表示形式,包括条件、map、reduce、finalize 和 out 选项。
203 204 205 206 207 208 209 210 211 212 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 203 def 检查 %(#<Mongoid::Contextual::MapReduce Selector: #{riteria.selector.inspect} 类: #{riteria.klass} map: #{command[:map]} reduce: #{command[:reduce]} finalize: #{command[:finalize]} out: #{command[:out].inspect}> ) end |
#js_mode ⇒ MapReduce
将 map/reduce 设置为使用 jsMode。
95 96 97 98 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 95 def js_mode @map_reduce = @map_reduce.js_mode(true) self end |
# out (位置) ⇒ MapReduce
指定 map/reduce 输出的存储位置。 请参阅 MongoDB 文档以了解支持的 map reduce 选项。
121 122 123 124 125 126 127 128 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 121 def out(位置) 标准化 = 位置.dup 标准化.transform_values! do |值| 值.is_a?(::符号) ? 值.to_s : 值 end @map_reduce = @map_reduce.out(标准化) self end |
#output ⇒ Integer
获取 map/reduce 输出的文档数。
136 137 138 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 136 def 输出 counts['output'] end |
#原始⇒哈希也称为:结果、执行
获取 map/reduce 操作的原始输出。
146 147 148 149 150 151 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 146 def 原始 validate_out! cmd = 命令 opts = { 读取: 条件..获取(:read) } if 条件.[:read] @map_reduce.database.命令(cmd, (opts || {}).合并(merge)(会话: _session)).first end |
# Reduced ⇒整数
获取通过 map/reduce 减少的文档数。
169 170 171 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 169 def 减少 counts['reduce'] end |
#作用域(对象) ⇒ MapReduce
将 JavaScript对象添加到 map/reduce 的全局范围。
181 182 183 184 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 181 def 范围(对象) @map_reduce = @map_reduce.范围(对象) self end |
# time ⇒ Float
获取 map/reduce 的执行时间。
192 193 194 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 192 def 时间 结果[' timeMillis '] end |