Sha256: f5a36aeda3f727985686d413b094acacc7f459b652fc03a15766fce5bb26bd0e

Contents?: true

Size: 944 Bytes

Versions: 12

Compression:

Stored size: 944 Bytes

Contents

module Riak
  module Crdt
    # A map that queues up its operations for the parent {Map} to send to
    # Riak all at once.
    class BatchMap
      attr_reader :counters, :flags, :maps, :registers, :sets

      # @api private
      def initialize(parent)
        @parent = parent
        @queue = []

        initialize_collections
      end

      # @api private
      def operate(operation)
        @queue << operation
      end

      # @api private
      def operations
        @queue.map do |q|
          Operation::Update.new.tap do |op|
            op.type = :map
            op.value = q
          end
        end
      end

      private
      def initialize_collections
        @counters = @parent.counters.reparent self
        @flags = @parent.flags.reparent self
        @maps = @parent.maps.reparent self
        @registers = @parent.registers.reparent self
        @sets = @parent.sets.reparent self
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
riak-client-2.6.0 lib/riak/crdt/batch_map.rb
riak-client-2.5.0 lib/riak/crdt/batch_map.rb
riak-client-2.4.1 lib/riak/crdt/batch_map.rb
riak-client-2.4.0 lib/riak/crdt/batch_map.rb
riak-client-2.4.0.pre1 lib/riak/crdt/batch_map.rb
riak-client-2.3.2 lib/riak/crdt/batch_map.rb
riak-client-2.3.1 lib/riak/crdt/batch_map.rb
riak-client-2.3.0 lib/riak/crdt/batch_map.rb
riak-client-2.2.2 lib/riak/crdt/batch_map.rb
riak-client-2.2.1 lib/riak/crdt/batch_map.rb
riak-client-noenc-1.0.0 lib/riak/crdt/batch_map.rb
riak-client-2.2.0 lib/riak/crdt/batch_map.rb