Class: Aerospike::BatchIndexNode

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

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, keys_with_idx) ⇒ BatchIndexNode

Returns a new instance of BatchIndexNode.



31
32
33
34
# File 'lib/aerospike/command/batch_index_node.rb', line 31

def initialize(node, keys_with_idx)
  @node = node
  @keys_by_idx = keys_with_idx.map(&:reverse).to_h
end

Instance Attribute Details

#keys_by_idxObject

Returns the value of attribute keys_by_idx.



23
24
25
# File 'lib/aerospike/command/batch_index_node.rb', line 23

def keys_by_idx
  @keys_by_idx
end

#nodeObject

Returns the value of attribute node.



22
23
24
# File 'lib/aerospike/command/batch_index_node.rb', line 22

def node
  @node
end

Class Method Details

.generate_list(cluster, replica_policy, keys) ⇒ Object



25
26
27
28
29
# File 'lib/aerospike/command/batch_index_node.rb', line 25

def self.generate_list(cluster, replica_policy, keys)
  keys.each_with_index
    .group_by { |key, _| cluster.get_node_for_key(replica_policy, key) }
    .map { |node, keys_with_idx| BatchIndexNode.new(node, keys_with_idx) }
end

Instance Method Details

#each_key_with_indexObject



40
41
42
43
44
# File 'lib/aerospike/command/batch_index_node.rb', line 40

def each_key_with_index
  keys_by_idx.each do |idx, key|
    yield key, idx
  end
end

#key_for_index(idx) ⇒ Object



46
47
48
# File 'lib/aerospike/command/batch_index_node.rb', line 46

def key_for_index(idx)
  keys_by_idx[idx]
end

#keysObject



36
37
38
# File 'lib/aerospike/command/batch_index_node.rb', line 36

def keys
  keys_by_idx.values
end