jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
simple_storage.cpp
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 #include "simple_storage.hpp"
18 
19 #include <string>
20 #include <vector>
21 
22 namespace jubatus {
23 namespace core {
24 namespace clustering {
25 
27  const std::string& name,
28  const clustering_config& config)
29  : storage(name, config) {
30 }
31 
32 void simple_storage::add(const weighted_point& point) {
33  static size_t cnt = 0;
34  ++cnt;
35  if (cnt % config_.bucket_size == 0) {
37  }
38  mine_.push_back(point);
39 }
40 
42  return mine_;
43 }
44 
46  packer.pack_array(2);
47  storage::pack_impl_(packer);
48  packer.pack(mine_);
49 }
50 
51 void simple_storage::unpack_impl_(msgpack::object o) {
52  std::vector<msgpack::object> mems;
53  o.convert(&mems);
54  if (mems.size() != 2) {
55  throw msgpack::type_error();
56  }
57  storage::unpack_impl_(mems[0]);
58  mems[1].convert(&mine_);
59 }
60 
63  mine_.clear();
64 }
65 
66 } // namespace clustering
67 } // namespace core
68 } // namespace jubatus
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
void add(const weighted_point &point)
void pack_impl_(framework::packer &packer) const
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
simple_storage(const std::string &name, const clustering_config &config)