Class: Jubatus::Clustering::IndexedPoint

Inherits:
Object
  • Object
show all
Includes:
Jubatus::Common
Defined in:
lib/jubatus/clustering/types.rb

Constant Summary collapse

TYPE =
TTuple.new(TString.new, TDatum.new)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Jubatus::Common

check_type, check_types

Constructor Details

#initialize(id, point) ⇒ IndexedPoint

Returns a new instance of IndexedPoint.


47
48
49
50
# File 'lib/jubatus/clustering/types.rb', line 47

def initialize(id, point)
  @id = id
  @point = point
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


71
72
73
# File 'lib/jubatus/clustering/types.rb', line 71

def id
  @id
end

#pointObject (readonly)

Returns the value of attribute point


71
72
73
# File 'lib/jubatus/clustering/types.rb', line 71

def point
  @point
end

Class Method Details

.from_msgpack(m) ⇒ Object


57
58
59
60
# File 'lib/jubatus/clustering/types.rb', line 57

def IndexedPoint.from_msgpack(m)
  val = TYPE.from_msgpack(m)
  IndexedPoint.new(*val)
end

Instance Method Details

#to_msgpack(out = '') ⇒ Object


52
53
54
55
# File 'lib/jubatus/clustering/types.rb', line 52

def to_msgpack(out = '')
  t = [@id, @point]
  return TYPE.to_msgpack(t)
end

#to_sObject


62
63
64
65
66
67
68
69
# File 'lib/jubatus/clustering/types.rb', line 62

def to_s
  gen = Jubatus::Common::MessageStringGenerator.new
  gen.open("indexed_point")
  gen.add("id", @id)
  gen.add("point", @point)
  gen.close()
  return gen.to_s
end