Sha256: a1a0a393229ff46633dd8940ca430222ec731db614a964f33774a42903523d6f
Contents?: true
Size: 730 Bytes
Versions: 6
Compression:
Stored size: 730 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
6 entries across 6 versions & 1 rubygems