Class: Aerospike::BatchOperateNode
- Inherits:
-
Object
- Object
- Aerospike::BatchOperateNode
- Defined in:
- lib/aerospike/command/batch_operate_node.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#node ⇒ Object
Returns the value of attribute node.
-
#records_by_idx ⇒ Object
Returns the value of attribute records_by_idx.
Class Method Summary collapse
Instance Method Summary collapse
- #each_record_with_index ⇒ Object
-
#initialize(node, records_with_idx) ⇒ BatchOperateNode
constructor
A new instance of BatchOperateNode.
- #record_for_index(idx) ⇒ Object
- #records ⇒ Object
Constructor Details
#initialize(node, records_with_idx) ⇒ BatchOperateNode
Returns a new instance of BatchOperateNode.
30 31 32 33 |
# File 'lib/aerospike/command/batch_operate_node.rb', line 30 def initialize(node, records_with_idx) @node = node @records_by_idx = records_with_idx.map(&:reverse).to_h end |
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
22 23 24 |
# File 'lib/aerospike/command/batch_operate_node.rb', line 22 def node @node end |
#records_by_idx ⇒ Object
Returns the value of attribute records_by_idx.
22 23 24 |
# File 'lib/aerospike/command/batch_operate_node.rb', line 22 def records_by_idx @records_by_idx end |
Class Method Details
.generate_list(cluster, replica_policy, records) ⇒ Object
24 25 26 27 28 |
# File 'lib/aerospike/command/batch_operate_node.rb', line 24 def self.generate_list(cluster, replica_policy, records) records.each_with_index .group_by { |record, _| cluster.get_node_for_key(replica_policy, record.key, is_write: record.has_write) } .map { |node, records_with_idx| BatchOperateNode.new(node, records_with_idx) } end |
Instance Method Details
#each_record_with_index ⇒ Object
39 40 41 42 43 |
# File 'lib/aerospike/command/batch_operate_node.rb', line 39 def each_record_with_index records_by_idx.each do |idx, rec| yield rec, idx end end |
#record_for_index(idx) ⇒ Object
45 46 47 |
# File 'lib/aerospike/command/batch_operate_node.rb', line 45 def record_for_index(idx) @records_by_idx[idx] end |
#records ⇒ Object
35 36 37 |
# File 'lib/aerospike/command/batch_operate_node.rb', line 35 def records records_by_idx.values end |