类:Mongo::BulkWrite
- 继承:
-
对象
- 对象
- Mongo::BulkWrite
- 扩展方式:
- 可转发
- 定义于:
- lib/ Mongo/bulk_write.rb ,
lib/ Mongo/bulk_write/result.rb,
lib/ Mongo/bulk_write/combineable.rb,
lib/ Mongo/bulk_write/validatable.rb,
lib/ Mongo/bulk_write/transformable.rb,
lib/ Mongo/bulk_write/result_combiner.rb、lib/
Mongo/bulk_write/ordered_combiner.rb、lib/
Mongo/bulk_write/unordered_combiner.rb
在命名空间下定义
模块: 组合、可 转换 、 可验证 类: OrderedCombiner 、 Result 、 ResultCombiner 、 UnorderedCombiner
实例属性摘要折叠
-
# 集合 ⇒ Mongo::Collection
只读
集合集合。
-
#options ⇒ Hash, BSON::Document
只读
选项 选项。
-
# requests ⇒ Array<Hash, BSON::Document>
只读
请求 请求。
实例方法摘要折叠
-
#执行⇒ Mongo::BulkWrite::Result
执行批量写入操作。
-
#initialize (collection, requests, options = {}) ⇒ BulkWrite
构造函数
private
创建新的批量写入操作。
-
#已订购? ⇒ true, false
private
批量写入是否已排序?
-
# write_concern (session = nil) ⇒ WriteConcern
private
获取批量写入的写关注(write concern)。
构造函数详情
#initialize (collection, requests, options = {}) ⇒ BulkWrite
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
创建新的批量写入操作。
128 129 130 131 132 133 134 135 |
# File 'lib/ Mongo/bulk_write.rb', 第 128 行 def 初始化(集合, requests, = {}) @collection = 集合 @requests = requests @options = || {} if @options[:timeout_ms] && @options[:timeout_ms] < 0 提高 ArgumentError, “ timeout_ms 选项必须是非负整数 ” end end |
实例属性详细信息
# 集合 ⇒ Mongo::Collection (只读)
返回集合集合。
32 33 34 |
# File 'lib/ Mongo/bulk_write.rb', 第 32 行 def 集合 @collection end |
# options ⇒ Hash , BSON::Document (readonly)
返回 options 选项。
38 39 40 |
# File 'lib/ Mongo/bulk_write.rb', 第 38 行 def @options end |
# requests ⇒ Array<Hash, BSON::Document> (只读)
返回 requests 请求。
35 36 37 |
# File 'lib/ Mongo/bulk_write.rb', 第 35 行 def requests @requests end |
实例方法详细信息
#执行⇒ Mongo::BulkWrite::Result
执行批量写入操作。
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ Mongo/bulk_write.rb', 第 58 行 def 执行 operation_id = 监控.next_operation_id result_combiner = ResultCombiner.new 操作 = op_combiner.结合 validate_requests! 截止日期 = 计算截止日期 客户端.with_session(@options) do |会话| 操作.每 do |操作| 上下文 = 操作::上下文.new( 客户端: 客户端, 会话: 会话, operation_timeups: { operation_timeout_ms: op_timeout_ms(截止日期) } ) if single_statement?(操作) write_concern = write_concern(会话) write_with_retry(write_concern, 上下文: 上下文) do |连接, txn_num, 上下文| execute_operation( 操作.密钥.first, 操作.values.展平, 连接, 上下文, operation_id, result_combiner, 会话, txn_num) end else nro_write_with_retry(write_concern, 上下文: 上下文) do |连接, txn_num, 上下文| execute_operation( 操作.密钥.first, 操作.values.展平, 连接, 上下文, operation_id, result_combiner, 会话) end end end end result_combiner.结果 end |
#已订购? ⇒ true , false
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
批量写入是否已排序?
147 148 149 |
# File 'lib/ Mongo/bulk_write.rb', 第 147 行 def 已订购? @ordered ||= .获取(:ordered, true) end |
# write_concern (session = nil) ⇒ WriteConcern
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
获取批量写入的写关注(write concern)。
161 162 163 164 165 |
# File 'lib/ Mongo/bulk_write.rb', 第 161 行 def write_concern(会话 = nil) @write_concern ||= [:write_concern] ? writeConcern.获取([:write_concern]) : 集合.write_concern_with_session(会话) end |