Class: Aerospike::BatchItem

Inherits:
Object
  • Object
show all
Defined in:
lib/aerospike/command/batch_item.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index) ⇒ BatchItem

Returns a new instance of BatchItem.



45
46
47
# File 'lib/aerospike/command/batch_item.rb', line 45

def initialize(index)
  @index = index
end

Class Method Details

.generate_map(keys) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/aerospike/command/batch_item.rb', line 29

def self.generate_map(keys)
  key_map = {}
  keys.each_with_index do |key, i|
    item = key_map[key.digest]
    unless item
      item = BatchItem.new(i)
      key_map[key.digest] = item
    else
      item.add_duplicate(i)
    end
  end

  key_map
end

Instance Method Details

#add_duplicate(idx) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/aerospike/command/batch_item.rb', line 49

def add_duplicate(idx)
  unless @duplicates
    @duplicates = []
    @duplicates << @index
    @index = 0
  end

  @duplicates << idx
end

#indexObject



59
60
61
62
63
64
65
# File 'lib/aerospike/command/batch_item.rb', line 59

def index
  return @index unless @duplicates

  r = @duplicates[@index]
  @index+=1
  return r
end