Class: JayAPI::Elasticsearch::BatchCounter

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Attribute Details

#batch_sizeInteger (readonly)



21
22
23
# File 'lib/jay_api/elasticsearch/batch_counter.rb', line 21

def batch_size
  @batch_size
end

#start_currentInteger (readonly)



21
# File 'lib/jay_api/elasticsearch/batch_counter.rb', line 21

attr_reader :batch_size, :start_current, :start_next

#start_nextObject (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