Class: Jubatus::Common::TMap

Inherits:
Object
  • Object
show all
Defined in:
lib/jubatus/common/types.rb

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ TMap

Returns a new instance of TMap.


139
140
141
142
# File 'lib/jubatus/common/types.rb', line 139

def initialize(key, value)
  @key = key
  @value = value
end

Instance Method Details

#from_msgpack(m) ⇒ Object


144
145
146
147
148
149
150
151
# File 'lib/jubatus/common/types.rb', line 144

def from_msgpack(m)
  Jubatus::Common.check_type(m, Hash)
  dic = {}
  m.each do |k, v|
    dic[@key.from_msgpack(k)] = @value.from_msgpack(v)
  end
  return dic
end

#to_msgpack(m) ⇒ Object


153
154
155
156
157
158
159
160
# File 'lib/jubatus/common/types.rb', line 153

def to_msgpack(m)
  Jubatus::Common.check_type(m, Hash)
  dic = {}
  m.each do |k, v|
    dic[@key.to_msgpack(k)] = @value.to_msgpack(v)
  end
  return dic
end