jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
burst.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2014 Preferred Networks and Nippon Telegraph and Telephone Corporation.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License version 2.1 as published by the Free Software Foundation.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 #ifndef JUBATUS_CORE_DRIVER_BURST_HPP_
18 #define JUBATUS_CORE_DRIVER_BURST_HPP_
19 
20 #include <string>
21 #include <vector>
22 #include <map>
23 #include "../burst/burst.hpp"
24 #include "../framework/mixable.hpp"
25 #include "driver.hpp"
26 
27 namespace jubatus {
28 namespace core {
29 namespace driver {
30 
31 class burst : public driver_base {
32  public:
38 
39  explicit burst(jubatus::util::lang::shared_ptr<model_t> model)
40  : burst_(model), mixable_burst_(model) {
41  init_();
42  }
43  explicit burst(model_t* model) : burst_(model), mixable_burst_(burst_) {
44  init_();
45  }
46 
47  model_t* get_model() const {
48  return burst_.get();
49  }
50 
51  bool add_keyword(const std::string& keyword,
52  const keyword_params& params,
53  bool processed_in_this_server);
54  bool remove_keyword(const std::string& keyword);
55  bool remove_all_keywords();
56  keyword_list get_all_keywords() const;
57 
58  bool add_document(const std::string& str, double pos);
59  void calculate_results();
60  result_t get_result(const std::string& keyword) const;
61  result_t get_result_at(const std::string& keyword, double pos) const;
62  result_map get_all_bursted_results() const;
63  result_map get_all_bursted_results_at(double pos) const;
64 
65  void get_status(std::map<std::string, std::string>& status) const;
66 
67  bool has_been_mixed() const;
68  void set_processed_keywords(const std::vector<std::string>& keywords);
69 
70  void pack(framework::packer& pk) const;
71  void unpack(msgpack::object o);
72  void clear();
73 
74  private:
75  jubatus::util::lang::shared_ptr<model_t> burst_;
77 
78  void init_();
79 };
80 
81 } // namespace driver
82 } // namespace core
83 } // namespace jubatus
84 
85 #endif // JUBATUS_CORE_DRIVER_BURST_HPP_
result_map get_all_bursted_results_at(double pos) const
Definition: burst.cpp:88
bool add_keyword(const std::string &keyword, const keyword_params &params, bool processed_in_this_server)
Definition: burst.cpp:57
model_t * get_model() const
Definition: burst.hpp:47
burst(jubatus::util::lang::shared_ptr< model_t > model)
Definition: burst.hpp:39
bool add_document(const std::string &str, double pos)
Definition: burst.cpp:72
void pack(framework::packer &pk) const
Definition: burst.cpp:106
model_t::result_t result_t
Definition: burst.hpp:34
core::burst::mixable_burst mixable_burst_
Definition: burst.hpp:76
keyword_list get_all_keywords() const
Definition: burst.cpp:68
model_t::result_map result_map
Definition: burst.hpp:35
jubatus::core::burst::keyword_params keyword_params
Definition: burst.hpp:36
void get_status(std::map< std::string, std::string > &status) const
Definition: burst.cpp:92
void unpack(msgpack::object o)
Definition: burst.cpp:109
jubatus::core::burst::burst model_t
Definition: burst.hpp:33
bool remove_keyword(const std::string &keyword)
Definition: burst.cpp:62
result_map get_all_bursted_results() const
Definition: burst.cpp:85
jubatus::util::lang::shared_ptr< model_t > burst_
Definition: burst.hpp:75
jubatus::util::data::unordered_map< std::string, result_t > result_map
Definition: burst.hpp:73
burst(model_t *model)
Definition: burst.hpp:43
void set_processed_keywords(const std::vector< std::string > &keywords)
Definition: burst.cpp:102
bool has_been_mixed() const
Definition: burst.cpp:99
model_t::keyword_list keyword_list
Definition: burst.hpp:37
result_t get_result_at(const std::string &keyword, double pos) const
Definition: burst.cpp:81
result_t get_result(const std::string &keyword) const
Definition: burst.cpp:78
std::vector< keyword_with_params > keyword_list
Definition: burst.hpp:74