Sha256: 36ea4897522996fb97207da64f5f9f420979e4ba16e62784fbf54b9d85e3ff93
Contents?: true
Size: 728 Bytes
Versions: 5
Compression:
Stored size: 728 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
5 entries across 5 versions & 1 rubygems