Sha256: a66889bafe2593ac34fea526e11367f68acfa6cf3ed2196a81dc45992919b893
Contents?: true
Size: 844 Bytes
Versions: 16
Compression:
Stored size: 844 Bytes
Contents
module Scrivito class ObjSearchEnumerator class BatchIterator def initialize(workspace, query, initial_batch) @query = query @executor = Scrivito::ObjSearchEnumerator::QueryExecutor.new(workspace) @all_fetched_ids = Set.new @initial_batch = initial_batch end attr_reader :total def each current_batch = initial_batch || fetch_batch loop do yield current_batch break unless current_batch.continuation current_batch = fetch_batch(current_batch.continuation) end @total = @all_fetched_ids.size end private attr_reader :query, :executor, :initial_batch def fetch_batch(continuation=nil) batch = executor.call(query, continuation, @all_fetched_ids) @all_fetched_ids += batch.objs.map(&:id) batch end end end end
Version data entries
16 entries across 16 versions & 1 rubygems