Sha256: 9483d2983fd31c4b34e5627591c384ebe94bac123b0a411c1b7d990f948e9fc6
Contents?: true
Size: 834 Bytes
Versions: 71
Compression:
Stored size: 834 Bytes
Contents
module Scrivito class ObjSearchEnumerator class BatchIterator def initialize(workspace, query, initial_batch) @query = query @executor = 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
71 entries across 71 versions & 1 rubygems