Sha256: 39afe671b2ce39f24a964c906db1a56657c83b03d8ace13ffd535902ee8f642a

Contents?: true

Size: 607 Bytes

Versions: 124

Compression:

Stored size: 607 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

124 entries across 124 versions & 2 rubygems

Version Path
sessionm-cassandra_object-2.2.23 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.22 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.20 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.18 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.16 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.4.0 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.3.6 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.3.5 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.3.4 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.3.3 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.3.2 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.3.1 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.3.0 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.14 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.12 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.10 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.8 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.6 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.2.4 lib/cassandra_object/batches.rb
gotime-cassandra_object-2.2.3 lib/cassandra_object/batches.rb