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.3.9 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.3.8 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.3.6 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.3.5 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.3.4 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.3.3 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.3.2 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.3.1 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.3.0 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.55 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.54 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.53 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.52 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.51 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.50 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.49 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.48 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.47 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.46 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.2.45 lib/cassandra_object/batches.rb