jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
driver.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_DRIVER_HPP_
18 #define JUBATUS_CORE_DRIVER_DRIVER_HPP_
19 
20 #include <string>
21 #include <set>
22 #include <vector>
23 #include "../framework/model.hpp"
24 #include "../framework/linear_mixable.hpp"
25 #include "../framework/push_mixable.hpp"
26 
27 namespace jubatus {
28 namespace core {
29 namespace driver {
30 
31 class driver_base {
32  public:
34  virtual ~driver_base() {}
36  return &holder_;
37  }
38  std::vector<storage::version> get_versions() const;
39 
40  virtual void pack(framework::packer& packer) const = 0;
41  virtual void unpack(msgpack::object o) = 0;
42  virtual void clear() = 0;
43 
44  protected:
45  void register_mixable(framework::mixable* mixable);
46 
49  public:
50  std::set<std::string> mixables() const;
52 
53  // linear_mixable
54  framework::diff_object convert_diff_object(const msgpack::object&) const;
55  void mix(const msgpack::object& obj, framework::diff_object) const;
56  void get_diff(framework::packer&) const;
57  bool put_diff(const framework::diff_object& obj);
58 
59  // push_mixable
60  void get_argument(framework::packer&) const;
61  void pull(const msgpack::object& arg, framework::packer&) const;
62  void push(const msgpack::object&);
63 
64  std::vector<storage::version> get_versions() const;
65  private:
66  std::vector<mixable*> mixables_;
67  };
68 
70 
71  private:
72  driver_base(const driver_base&);
73  void operator=(const driver_base&);
74 };
75 
76 } // namespace driver
77 } // namespace core
78 } // namespace jubatus
79 
80 #endif // JUBATUS_CORE_DRIVER_DRIVER_HPP_
virtual framework::mixable * get_mixable()
Definition: driver.hpp:35
void get_diff(framework::packer &) const
Definition: driver.cpp:142
void pull(const msgpack::object &arg, framework::packer &) const
Definition: driver.cpp:191
jubatus::util::lang::shared_ptr< diff_object_raw > diff_object
void get_argument(framework::packer &) const
Definition: driver.cpp:179
bool put_diff(const framework::diff_object &obj)
Definition: driver.cpp:154
std::vector< storage::version > get_versions() const
Definition: driver.cpp:230
virtual void unpack(msgpack::object o)=0
virtual void pack(framework::packer &packer) const =0
void register_mixable(framework::mixable *mixable)
Definition: driver.cpp:84
framework::diff_object convert_diff_object(const msgpack::object &) const
Definition: driver.cpp:90
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
void mix(const msgpack::object &obj, framework::diff_object) const
Definition: driver.cpp:111
std::vector< storage::version > get_versions() const
Definition: driver.cpp:238
void operator=(const driver_base &)
std::set< std::string > mixables() const
Definition: driver.cpp:70
void register_mixable(framework::mixable *mixable)
Definition: driver.cpp:242