Class: Aerospike::MapValue

Inherits:
Value
  • Object
show all
Defined in:
lib/aerospike/value/value.rb

Overview

Map value. Supported by Aerospike 3 servers only.

Instance Method Summary collapse

Methods inherited from Value

of, validate_hash_key

Constructor Details

#initialize(vmap) ⇒ MapValue

:nodoc:



430
431
432
# File 'lib/aerospike/value/value.rb', line 430

def initialize(vmap)
  @vmap = vmap || {}
end

Instance Method Details

#estimate_sizeObject



434
435
436
# File 'lib/aerospike/value/value.rb', line 434

def estimate_size
  bytes.bytesize
end

#getObject



457
458
459
# File 'lib/aerospike/value/value.rb', line 457

def get
  @vmap
end

#pack(packer) ⇒ Object



443
444
445
446
447
448
449
450
451
# File 'lib/aerospike/value/value.rb', line 443

def pack(packer)
  packer.write_map_header(@vmap.length)
  for key, val in @vmap
    Value.validate_hash_key(key)

    Value.of(key).pack(packer)
    Value.of(val).pack(packer)
  end
end

#to_bytesObject



461
462
463
# File 'lib/aerospike/value/value.rb', line 461

def to_bytes
  bytes
end

#to_sObject



465
466
467
# File 'lib/aerospike/value/value.rb', line 465

def to_s
  @vmap.map{|k, v| "#{k.to_s} => #{v.to_s}" }.to_s
end

#typeObject



453
454
455
# File 'lib/aerospike/value/value.rb', line 453

def type
  Aerospike::ParticleType::MAP
end

#write(buffer, offset) ⇒ Object



438
439
440
441
# File 'lib/aerospike/value/value.rb', line 438

def write(buffer, offset)
  buffer.write_binary(bytes, offset)
  bytes.bytesize
end