提交 4f993520 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #29240 from tjschuck/ar_batches_doc_updates

Doc updates for ActiveRecord::Batches
...@@ -30,14 +30,14 @@ module Batches ...@@ -30,14 +30,14 @@ module Batches
# end # end
# #
# ==== Options # ==== Options
# * <tt>:batch_size</tt> - Specifies the size of the batch. Default to 1000. # * <tt>:batch_size</tt> - Specifies the size of the batch. Defaults to 1000.
# * <tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value. # * <tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value.
# * <tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value. # * <tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value.
# * <tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when # * <tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when
# an order is present in the relation. # an order is present in the relation.
# #
# Limits are honored, and if present there is no requirement for the batch # Limits are honored, and if present there is no requirement for the batch
# size, it can be less than, equal, or greater than the limit. # size: it can be less than, equal to, or greater than the limit.
# #
# The options +start+ and +finish+ are especially useful if you want # The options +start+ and +finish+ are especially useful if you want
# multiple workers dealing with the same processing queue. You can make # multiple workers dealing with the same processing queue. You can make
...@@ -89,14 +89,14 @@ def find_each(start: nil, finish: nil, batch_size: 1000, error_on_ignore: nil) ...@@ -89,14 +89,14 @@ def find_each(start: nil, finish: nil, batch_size: 1000, error_on_ignore: nil)
# To be yielded each record one by one, use #find_each instead. # To be yielded each record one by one, use #find_each instead.
# #
# ==== Options # ==== Options
# * <tt>:batch_size</tt> - Specifies the size of the batch. Default to 1000. # * <tt>:batch_size</tt> - Specifies the size of the batch. Defaults to 1000.
# * <tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value. # * <tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value.
# * <tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value. # * <tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value.
# * <tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when # * <tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when
# an order is present in the relation. # an order is present in the relation.
# #
# Limits are honored, and if present there is no requirement for the batch # Limits are honored, and if present there is no requirement for the batch
# size, it can be less than, equal, or greater than the limit. # size: it can be less than, equal to, or greater than the limit.
# #
# The options +start+ and +finish+ are especially useful if you want # The options +start+ and +finish+ are especially useful if you want
# multiple workers dealing with the same processing queue. You can make # multiple workers dealing with the same processing queue. You can make
...@@ -140,9 +140,9 @@ def find_in_batches(start: nil, finish: nil, batch_size: 1000, error_on_ignore: ...@@ -140,9 +140,9 @@ def find_in_batches(start: nil, finish: nil, batch_size: 1000, error_on_ignore:
# If you do not provide a block to #in_batches, it will return a # If you do not provide a block to #in_batches, it will return a
# BatchEnumerator which is enumerable. # BatchEnumerator which is enumerable.
# #
# Person.in_batches.with_index do |relation, batch_index| # Person.in_batches.each_with_index do |relation, batch_index|
# puts "Processing relation ##{batch_index}" # puts "Processing relation ##{batch_index}"
# relation.each { |relation| relation.delete_all } # relation.delete_all
# end # end
# #
# Examples of calling methods on the returned BatchEnumerator object: # Examples of calling methods on the returned BatchEnumerator object:
...@@ -152,8 +152,8 @@ def find_in_batches(start: nil, finish: nil, batch_size: 1000, error_on_ignore: ...@@ -152,8 +152,8 @@ def find_in_batches(start: nil, finish: nil, batch_size: 1000, error_on_ignore:
# Person.in_batches.each_record(&:party_all_night!) # Person.in_batches.each_record(&:party_all_night!)
# #
# ==== Options # ==== Options
# * <tt>:of</tt> - Specifies the size of the batch. Default to 1000. # * <tt>:of</tt> - Specifies the size of the batch. Defaults to 1000.
# * <tt>:load</tt> - Specifies if the relation should be loaded. Default to false. # * <tt>:load</tt> - Specifies if the relation should be loaded. Defaults to false.
# * <tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value. # * <tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value.
# * <tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value. # * <tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value.
# * <tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when # * <tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when
...@@ -186,7 +186,7 @@ def find_in_batches(start: nil, finish: nil, batch_size: 1000, error_on_ignore: ...@@ -186,7 +186,7 @@ def find_in_batches(start: nil, finish: nil, batch_size: 1000, error_on_ignore:
# #
# NOTE: It's not possible to set the order. That is automatically set to # NOTE: It's not possible to set the order. That is automatically set to
# ascending on the primary key ("id ASC") to make the batch ordering # ascending on the primary key ("id ASC") to make the batch ordering
# consistent. Therefore the primary key must be orderable, e.g an integer # consistent. Therefore the primary key must be orderable, e.g. an integer
# or a string. # or a string.
# #
# NOTE: By its nature, batch processing is subject to race conditions if # NOTE: By its nature, batch processing is subject to race conditions if
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册