Class: Jubatus::Clustering::WeightedIndex

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

Constant Summary collapse

TYPE =
TTuple.new(TFloat.new, TString.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(weight, id) ⇒ WeightedIndex

Returns a new instance of WeightedIndex.


79
80
81
82
# File 'lib/jubatus/clustering/types.rb', line 79

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


103
104
105
# File 'lib/jubatus/clustering/types.rb', line 103

def id
  @id
end

#weightObject (readonly)

Returns the value of attribute weight


103
104
105
# File 'lib/jubatus/clustering/types.rb', line 103

def weight
  @weight
end

Class Method Details

.from_msgpack(m) ⇒ Object


89
90
91
92
# File 'lib/jubatus/clustering/types.rb', line 89

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

Instance Method Details

#to_msgpack(out = '') ⇒ Object


84
85
86
87
# File 'lib/jubatus/clustering/types.rb', line 84

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

#to_sObject


94
95
96
97
98
99
100
101
# File 'lib/jubatus/clustering/types.rb', line 94

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