Class: JayAPI::Elasticsearch::BatchCounter
- Inherits:
-
Object
- Object
- JayAPI::Elasticsearch::BatchCounter
- Defined in:
- lib/jay_api/elasticsearch/batch_counter.rb
Overview
Manages and tracks the current batch within the QueryResults context. This class is responsible for keeping track of the current batch start position and calculating the start position for the next batch based on the batch size.
Constant Summary collapse
- DEFAULT_START =
The start of the batch to default to, if no other information is provided.
0
Instance Attribute Summary collapse
-
#batch_size ⇒ Integer
readonly
The size of each batch as determined by the query or the default size.
-
#start_current ⇒ Integer
readonly
The starting index of the current batch.
-
#start_next ⇒ Object
readonly
Returns the value of attribute start_next.
Class Method Summary collapse
-
.create_or_update(batch, query, size) ⇒ BatchCounter
Creates a new
BatchCounter
object by either updating a copy of the batch instance with new values or creates a new instance if none exists.
Instance Attribute Details
#batch_size ⇒ Integer (readonly)
Returns The size of each batch as determined by the query or the default size.
21 22 23 |
# File 'lib/jay_api/elasticsearch/batch_counter.rb', line 21 def batch_size @batch_size end |
#start_current ⇒ Integer (readonly)
Returns The starting index of the current batch.
21 |
# File 'lib/jay_api/elasticsearch/batch_counter.rb', line 21 attr_reader :batch_size, :start_current, :start_next |
#start_next ⇒ Object (readonly)
Returns the value of attribute start_next.
21 |
# File 'lib/jay_api/elasticsearch/batch_counter.rb', line 21 attr_reader :batch_size, :start_current, :start_next |
Class Method Details
.create_or_update(batch, query, size) ⇒ BatchCounter
Creates a new BatchCounter
object by either updating a copy of the batch instance with new values or creates a new instance if none exists.
29 30 31 32 33 34 35 |
# File 'lib/jay_api/elasticsearch/batch_counter.rb', line 29 def self.create_or_update(batch, query, size) if batch new(query, size, batch.start_next, batch.start_next + size, batch.batch_size) else new(query, size) end end |