Sha256: 63fe384685ccd5f88878a933c0417664e533278a48da1f5216e5df0a7574153b

Contents?: true

Size: 599 Bytes

Versions: 21

Compression:

Stored size: 599 Bytes

Contents

module CassandraObject
  module Batches
    extend ActiveSupport::Concern

    module ClassMethods
      def find_each
        connection.each(column_family) do |k, v|
          yield instantiate(k, v)
        end
      end

      def find_in_batches(options = {})
        batch_size = options.delete(:batch_size) || 1000

        batch = []

        find_each do |record|
          batch << record
          if batch.size == batch_size
            yield(batch)
            batch = []
          end
        end

        if batch.size > 0
          yield batch
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
gotime-cassandra_object-2.7.12 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.11 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.10 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.9 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.8 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.7 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.6 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.5 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.4 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.3 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.2 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.1 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.7.0 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.6.4 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.6.3 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.6.2 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.6.1 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.6.0 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.5.0 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.4.2 lib/cassandra_object/batches.rb