类:Mongoid::Contextual::MapReduce
- 继承:
-
对象
- 对象
- Mongoid::Contextual::MapReduce
- 扩展方式:
- 可转发
- 包括:
- 可枚举,命令
- 定义于:
- lib/mongoid/contextual/map_reduce.rb
Overview
表示 mapReduce数据库命令指令。
实例属性摘要
命令包含的属性
# 集合 , # 集合要查询的集合。 、 #criteria 、 #criteria 上下文的条件。
实例方法摘要折叠
-
#命令⇒ 哈希
返回命令规范的选择器。
-
# counts ⇒ 哈希
获取 map/reduce 返回的所有计数。
-
#each ⇒ 枚举器
遍历 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 指令。
77 78 79 80 81 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 77 def 初始化(集合, 条件, map, 化简(reduce)) @collection = 集合 @criteria = 条件 @map_reduce = @criteria.查看.map_reduce(map, 化简(reduce)) end |
实例方法详细信息
#命令⇒哈希
返回命令规范的选择器。
221 222 223 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 221 def 命令 @map_reduce.发送(:map_reduce_spec)[:selector] end |
# counts ⇒哈希
获取 map/reduce 返回的所有计数。
22 23 24 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 22 def counts 结果[" counts "] end |
#each ⇒枚举器
遍历 map/reduce 中的每个文档,不包括从数据库传回的额外信息。
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 35 def 每 validate_out! if block_given? @map_reduce.每 do |doc| 产量 doc end else @map_reduce.to_enum end end |
发出的数量 ⇒整数
获取 map/reduce 发出的文档数量。
52 53 54 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 52 def 发出 counts[" emit "] end |
# finalize (function) ⇒ MapReduce
为 map/reduce 提供 finalize JavaScript函数。
64 65 66 67 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 64 def finalize(function) @map_reduce = @map_reduce.finalize(function) self end |
#input ⇒ Integer
获取输入到 map/reduce 中的文档数。
89 90 91 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 89 def 输入 counts[" input "] end |
#检查⇒ string
获取 map/reduce 的美观string表示形式,包括条件、map、reduce、finalize 和 out 选项。
207 208 209 210 211 212 213 214 215 216 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 207 def 检查 %Q{ #<Mongoid::Contextual::MapReduce 选择器: #{ riteria .选择器。检查}类: #{条件. klass } map: #{ command [ :map ] } reduce: #{ command [ :reduce ] } finalize: #{ command [ :finalize ] } out: #{ command [ :out ] .检查} > } end |
#js_mode ⇒ MapReduce
将 map/reduce 设置为使用 jsMode。
99 100 101 102 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 99 def js_mode @map_reduce = @map_reduce.js_mode(true) self end |
# out (位置) ⇒ MapReduce
指定 map/reduce 输出的存储位置。 请参阅 MongoDB 文档以了解支持的 map reduce 选项。
125 126 127 128 129 130 131 132 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 125 def out(位置) 标准化 = 位置.dup 标准化.transform_values! do |值| 值.is_a?(::符号) ? 值.to_s : 值 end @map_reduce = @map_reduce.out(标准化) self end |
#output ⇒ Integer
获取 map/reduce 输出的文档数。
140 141 142 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 140 def 输出 counts[" output "] end |
#原始⇒哈希也称为:结果、执行
获取 map/reduce 操作的原始输出。
150 151 152 153 154 155 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 150 def 原始 validate_out! cmd = 命令 opts = { 读取: 条件..获取(:read) } if 条件.[:read] @map_reduce.database.命令(cmd, (opts || {}).合并(merge)(会话: _session)).first end |
# Reduced ⇒整数
获取通过 map/reduce 减少的文档数。
173 174 175 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 173 def 减少 counts[" reduce "] end |
#作用域(对象) ⇒ MapReduce
将 JavaScript对象添加到 map/reduce 的全局范围。
185 186 187 188 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 185 def 范围(对象) @map_reduce = @map_reduce.范围(对象) self end |
# time ⇒ Float
获取 map/reduce 的执行时间。
196 197 198 |
# File 'lib/mongoid/contextual/map_reduce.rb', line 196 def 时间 结果[" timeMillis "] end |