Class: FluentdJubatus
- Inherits:
-
Object
- Object
- FluentdJubatus
- Defined in:
- lib/fluent/plugin/jubatus.rb
Class Method Summary collapse
Instance Method Summary collapse
- #analyze(type, datum, num = 10) ⇒ Object
- #close ⇒ Object
-
#initialize(type, host, port, name = '') ⇒ FluentdJubatus
constructor
A new instance of FluentdJubatus.
- #learn(type, datum, key = nil) ⇒ Object
- #set_datum(data, keys) ⇒ Object
Constructor Details
#initialize(type, host, port, name = '') ⇒ FluentdJubatus
Returns a new instance of FluentdJubatus.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fluent/plugin/jubatus.rb', line 11 def initialize(type, host, port, name='') @jubatus = case type when /anomaly/i Jubatus::Anomaly::Client::Anomaly.new(host, port, name) when /classifier/i Jubatus::Classifier::Client::Classifier.new(host, port, name) when /clustering/i Jubatus::Clustering::Client::Clustering.new(host, port, name) when /recommender/i Jubatus::Recommender::Client::Recommender.new(host, port, name) end end |
Class Method Details
.fix_result(type, result) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fluent/plugin/jubatus.rb', line 54 def self.fix_result(type, result) case type when /anomaly/i fix_anomaly(result) when /classifier/i fix_classifier(result) when /clustering/i fix_clustering(result) when /recommender/i fix_clustering(result) end end |
Instance Method Details
#analyze(type, datum, num = 10) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fluent/plugin/jubatus.rb', line 33 def analyze(type, datum, num = 10) case type when /anomaly/i @jubatus.calc_score(datum) when /classifier/i @jubatus.classify([datum]) when /clustering/i @jubatus.get_nearest_members(datum) when /recommender/i @jubatus.similar_row_from_datum(datum, num) end end |
#close ⇒ Object
46 47 48 |
# File 'lib/fluent/plugin/jubatus.rb', line 46 def close @jubatus.get_client.close end |
#learn(type, datum, key = nil) ⇒ Object
50 51 52 |
# File 'lib/fluent/plugin/jubatus.rb', line 50 def learn(type, datum, key = nil) # todo end |
#set_datum(data, keys) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/fluent/plugin/jubatus.rb', line 24 def set_datum(data, keys) datum = {} data.each do |k,v| datum[k.to_s] = v.to_f if keys[:num].include?(k.to_s) datum[k.to_s] = v.to_s if keys[:str].include?(k.to_s) end Jubatus::Common::Datum.new(datum) end |