Sha256: c1aa14be809516a5a361523fd8071fc678db062edfcc5de9d970fceabc35d3d9
Contents?: true
Size: 731 Bytes
Versions: 23
Compression:
Stored size: 731 Bytes
Contents
module CassandraObject class Scope module Batches def find_each(options = {}) find_in_batches(options) do |records| records.each { |record| yield record } end end def find_in_batches(options = {}) batch_size = options.delete(:batch_size) || 1000 start_key = nil scope = limit(batch_size + 1) records = scope.to_a while records.any? if records.size > batch_size next_record = records.pop else next_record = nil end yield records break if next_record.nil? records = scope.where("KEY >= '#{next_record.id}'").to_a end end end end end
Version data entries
23 entries across 23 versions & 2 rubygems