jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
mixable_versioned_table.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2013 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_FRAMEWORK_MIXABLE_VERSIONED_TABLE_HPP_
18 #define JUBATUS_CORE_FRAMEWORK_MIXABLE_VERSIONED_TABLE_HPP_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 #include "../common/version.hpp"
24 #include "../framework/push_mixable.hpp"
25 #include "../framework/linear_mixable.hpp"
26 #include "../storage/column_table.hpp"
27 #include "../unlearner/unlearner_base.hpp"
28 
29 namespace jubatus {
30 namespace core {
31 namespace framework {
32 
33 typedef std::map<storage::owner, uint64_t> version_clock;
34 
37  public:
38  typedef jubatus::util::lang::shared_ptr<storage::column_table> model_ptr;
39 
41  jubatus::util::lang::shared_ptr<unlearner::unlearner_base> unlearner) {
43  }
44 
45  // linear mixable
46  framework::diff_object convert_diff_object(const msgpack::object&) const;
47  void mix(const msgpack::object& obj, framework::diff_object) const;
48  void get_diff(framework::packer&) const;
49  bool put_diff(const framework::diff_object& obj);
50 
51  // push mixable
52  void get_argument(framework::packer& pk) const;
53  void pull(const msgpack::object& arg, framework::packer& pk) const;
54  void push(const msgpack::object& diff);
55 
57  return storage::version();
58  }
59 
60  void set_model(model_ptr m) {
61  model_ = m;
62  }
63 
64  model_ptr get_model() const {
65  return model_;
66  }
67 
68  void clear() {}
69 
70  private:
71  void pull_impl(const version_clock& vc, framework::packer&) const;
72  void push_impl(const msgpack::object&);
73 
75 
76  model_ptr model_;
77  jubatus::util::lang::shared_ptr<unlearner::unlearner_base> unlearner_;
78  version_clock vc_;
79 };
80 
81 } // namespace framework
82 } // namespace core
83 } // namespace jubatus
84 
85 #endif // JUBATUS_CORE_FRAMEWORK_MIXABLE_VERSIONED_TABLE_HPP_
bool put_diff(const framework::diff_object &obj)
jubatus::util::lang::shared_ptr< diff_object_raw > diff_object
void pull_impl(const version_clock &vc, framework::packer &) const
jubatus::util::data::optional< std::string > unlearner
void update_version(const storage::column_table::version_t &version)
jubatus::util::lang::shared_ptr< unlearner::unlearner_base > unlearner_
void pull(const msgpack::object &arg, framework::packer &pk) const
std::pair< owner, uint64_t > version_t
jubatus::util::lang::shared_ptr< storage::column_table > model_ptr
framework::diff_object convert_diff_object(const msgpack::object &) const
void set_unlearner(jubatus::util::lang::shared_ptr< unlearner::unlearner_base > unlearner)
void mix(const msgpack::object &obj, framework::diff_object) const
std::map< storage::owner, uint64_t > version_clock