Class: Aerospike::MapValue
Overview
Map value. Supported by Aerospike 3 servers only.
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:
324 325 326 327 328 329 330 331 332 333 |
# File 'lib/aerospike/value/value.rb', line 324 def initialize(vmap) @vmap = vmap || {} Packer.use do |packer| pack(packer) @bytes = packer.bytes end self end |
Instance Method Details
#estimate_size ⇒ Object
335 336 337 |
# File 'lib/aerospike/value/value.rb', line 335 def estimate_size @bytes.bytesize end |
#get ⇒ Object
357 358 359 |
# File 'lib/aerospike/value/value.rb', line 357 def get @vmap end |
#pack(packer) ⇒ Object
344 345 346 347 348 349 350 351 |
# File 'lib/aerospike/value/value.rb', line 344 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
361 362 363 |
# File 'lib/aerospike/value/value.rb', line 361 def to_bytes @bytes end |
#to_s ⇒ Object
365 366 367 |
# File 'lib/aerospike/value/value.rb', line 365 def to_s @vmap.map{|k, v| "#{k.to_s} => #{v.to_s}" }.to_s end |
#type ⇒ Object
353 354 355 |
# File 'lib/aerospike/value/value.rb', line 353 def type Aerospike::ParticleType::MAP end |
#write(buffer, offset) ⇒ Object
339 340 341 342 |
# File 'lib/aerospike/value/value.rb', line 339 def write(buffer, offset) buffer.write_binary(@bytes, offset) @bytes.bytesize end |