jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
storage.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_CLUSTERING_STORAGE_HPP_
18 #define JUBATUS_CORE_CLUSTERING_STORAGE_HPP_
19 
20 #include <string>
21 #include <utility>
22 #include <vector>
23 #include <msgpack.hpp>
24 #include "../framework/mixable_helper.hpp"
25 #include "../common/version.hpp"
26 #include "clustering_config.hpp"
27 #include "types.hpp"
28 #include "event_dispatcher.hpp"
29 
30 namespace jubatus {
31 namespace core {
32 namespace clustering {
33 
37 };
38 
39 class storage : public event_dispatcher<storage_event_type, wplist> {
40  public:
41  storage(const std::string& name, const clustering_config& config);
42  virtual ~storage() {}
43 
44  void get_diff(diff_t& d) const;
45  bool put_diff(const diff_t& d);
46  void mix(const diff_t&, diff_t& ret);
47 
48  size_t get_revision();
49 
50  virtual void add(const weighted_point& point) = 0;
51  virtual wplist get_mine() const = 0;
52 
53  virtual wplist get_all() const;
54  virtual wplist get_common() const;
55 
57  return core::storage::version();
58  }
59 
60  void pack(framework::packer& packer) const;
61  void unpack(msgpack::object o);
62  void clear();
63 
65 
66  protected:
67  void increment_revision();
68  virtual void pack_impl_(framework::packer& packer) const;
69  virtual void unpack_impl_(msgpack::object o);
70  virtual void clear_impl_();
71 
72  size_t revision_;
73  std::string name_;
75 
76  std::vector<std::pair<std::string, wplist> > common_;
77 };
78 
80 
81 } // namespace clustering
82 } // namespace core
83 } // namespace jubatus
84 
85 #endif // JUBATUS_CORE_CLUSTERING_STORAGE_HPP_
virtual wplist get_common() const
Definition: storage.cpp:41
void unpack(msgpack::object o)
Definition: storage.cpp:92
virtual wplist get_all() const
Definition: storage.cpp:34
framework::linear_mixable_helper< storage, diff_t > mixable_storage
Definition: storage.hpp:79
void mix(const diff_t &, diff_t &ret)
Definition: storage.cpp:69
std::vector< std::pair< std::string, wplist > > common_
Definition: storage.hpp:76
storage(const std::string &name, const clustering_config &config)
Definition: storage.cpp:28
void pack(framework::packer &packer) const
Definition: storage.cpp:88
void get_diff(diff_t &d) const
Definition: storage.cpp:50
virtual wplist get_mine() const =0
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
std::vector< std::pair< std::string, wplist > > diff_t
Definition: types.hpp:57
virtual void add(const weighted_point &point)=0
core::storage::version get_version() const
Definition: storage.hpp:56
virtual void unpack_impl_(msgpack::object o)
Definition: storage.cpp:115
virtual void pack_impl_(framework::packer &packer) const
Definition: storage.cpp:112
std::vector< weighted_point > wplist
Definition: types.hpp:55
MSGPACK_DEFINE(revision_, name_, config_, common_)
bool put_diff(const diff_t &d)
Definition: storage.cpp:56