Class: Aerospike::MapValue
Overview
Map value. Supported by Aerospike 3 servers only.
Constant Summary
Constants inherited from Value
Instance Method Summary collapse
- #estimate_size ⇒ Object
- #get ⇒ Object
-
#initialize(vmap) ⇒ MapValue
constructor
:nodoc:.
- #pack(packer) ⇒ Object
- #to_bytes ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #write(buffer, offset) ⇒ Object
Methods inherited from Value
Constructor Details
#initialize(vmap) ⇒ MapValue
:nodoc:
407 408 409 410 411 412 413 414 415 416 |
# File 'lib/aerospike/value/value.rb', line 407 def initialize(vmap) @vmap = vmap || {} Packer.use do |packer| pack(packer) @bytes = packer.bytes end self end |
Instance Method Details
#estimate_size ⇒ Object
418 419 420 |
# File 'lib/aerospike/value/value.rb', line 418 def estimate_size @bytes.bytesize end |
#get ⇒ Object
440 441 442 |
# File 'lib/aerospike/value/value.rb', line 440 def get @vmap end |
#pack(packer) ⇒ Object
427 428 429 430 431 432 433 434 |
# File 'lib/aerospike/value/value.rb', line 427 def pack(packer) packer.write_map_header(@vmap.length) # @vmap.each do |key, val| for key, val in @vmap Value.of(key).pack(packer) Value.of(val).pack(packer) end end |
#to_bytes ⇒ Object
444 445 446 |
# File 'lib/aerospike/value/value.rb', line 444 def to_bytes @bytes end |
#to_s ⇒ Object
448 449 450 |
# File 'lib/aerospike/value/value.rb', line 448 def to_s @vmap.map{|k, v| "#{k.to_s} => #{v.to_s}" }.to_s end |
#type ⇒ Object
436 437 438 |
# File 'lib/aerospike/value/value.rb', line 436 def type Aerospike::ParticleType::MAP end |
#write(buffer, offset) ⇒ Object
422 423 424 425 |
# File 'lib/aerospike/value/value.rb', line 422 def write(buffer, offset) buffer.write_binary(@bytes, offset) @bytes.bytesize end |