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-4.0.13 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.12 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.11 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.10 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.9 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.7.3 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.7.2 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.8 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.7 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.6 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.5 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.4 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.3 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.2 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.1 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.0 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.7.1 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.7.0 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.6.1 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.6.0 lib/cassandra_object/batches.rb