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.32 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.31 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.30 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.29 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.28 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.27 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.26 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.25 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.24 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.23 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.22 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.21 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.20 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.7.5 lib/cassandra_object/batches.rb
sessionm-cassandra_object-2.7.4 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.18 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.17 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.16 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.15 lib/cassandra_object/batches.rb
sessionm-cassandra_object-4.0.14 lib/cassandra_object/batches.rb