Class: Aerospike::Partition
- Inherits:
-
Object
- Object
- Aerospike::Partition
- Defined in:
- lib/aerospike/cluster/partition.rb
Overview
:nodoc:
Constant Summary collapse
- UNPACK_FORMAT =
'l<'
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#partition_id ⇒ Object
readonly
Returns the value of attribute partition_id.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(namespace, partition_id) ⇒ Partition
constructor
A new instance of Partition.
- #to_s ⇒ Object
Constructor Details
#initialize(namespace, partition_id) ⇒ Partition
Returns a new instance of Partition.
27 28 29 30 31 32 |
# File 'lib/aerospike/cluster/partition.rb', line 27 def initialize(namespace, partition_id) @namespace = namespace @partition_id = partition_id self end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
25 26 27 |
# File 'lib/aerospike/cluster/partition.rb', line 25 def namespace @namespace end |
#partition_id ⇒ Object (readonly)
Returns the value of attribute partition_id.
25 26 27 |
# File 'lib/aerospike/cluster/partition.rb', line 25 def partition_id @partition_id end |
Class Method Details
.new_by_key(key) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/aerospike/cluster/partition.rb', line 34 def self.new_by_key(key) Partition.new( key.namespace, (key.digest[0..3].unpack(UNPACK_FORMAT)[0] & 0xFFFF) % Node::PARTITIONS ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
45 46 47 48 |
# File 'lib/aerospike/cluster/partition.rb', line 45 def ==(other) other && other.is_a?(Partition) && @partition_id == other.partition_id && @namespace == other.namespace end |
#hash ⇒ Object
51 52 53 |
# File 'lib/aerospike/cluster/partition.rb', line 51 def hash to_s.hash end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/aerospike/cluster/partition.rb', line 41 def to_s "#{@namespace}:#{partition_id}" end |