Class: Aerospike::Partition
- Inherits:
-
Object
- Object
- Aerospike::Partition
- Defined in:
- lib/aerospike/cluster/partition.rb
Overview
:nodoc:
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.
24 25 26 27 28 29 |
# File 'lib/aerospike/cluster/partition.rb', line 24 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.
22 23 24 |
# File 'lib/aerospike/cluster/partition.rb', line 22 def namespace @namespace end |
#partition_id ⇒ Object (readonly)
Returns the value of attribute partition_id.
22 23 24 |
# File 'lib/aerospike/cluster/partition.rb', line 22 def partition_id @partition_id end |
Class Method Details
.new_by_key(key) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/aerospike/cluster/partition.rb', line 31 def self.new_by_key(key) Partition.new( key.namespace, (key.digest[0..3].unpack('l<')[0] & 0xFFFF) % Node::PARTITIONS ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
42 43 44 45 |
# File 'lib/aerospike/cluster/partition.rb', line 42 def ==(other) other && other.is_a?(Partition) && @partition_id == other.partition_id && @namespace == other.namespace end |
#hash ⇒ Object
48 49 50 |
# File 'lib/aerospike/cluster/partition.rb', line 48 def hash to_s.hash end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/aerospike/cluster/partition.rb', line 38 def to_s "#{@namespace}:#{partition_id}" end |