jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
sparse_matrix_storage.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2011 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_STORAGE_SPARSE_MATRIX_STORAGE_HPP_
18 #define JUBATUS_CORE_STORAGE_SPARSE_MATRIX_STORAGE_HPP_
19 
20 #include <string>
21 #include <utility>
22 #include <vector>
23 #include <msgpack.hpp>
24 #include "jubatus/util/data/unordered_map.h"
25 #include "../common/key_manager.hpp"
26 #include "../common/unordered_map.hpp"
27 #include "../framework/model.hpp"
28 #include "storage_type.hpp"
29 
30 namespace jubatus {
31 namespace core {
32 namespace storage {
33 
35  public:
38 
40 
41  void set(const std::string& row, const std::string& column, float val);
42  void set_row(
43  const std::string& row,
44  const std::vector<std::pair<std::string, float> >& columns);
45 
46  float get(const std::string& row, const std::string& column) const;
47  void get_row(
48  const std::string& row,
49  std::vector<std::pair<std::string, float> >& columns) const;
50 
51  float calc_l2norm(const std::string& row) const;
52  void remove(const std::string& row, const std::string& column);
53  void remove_row(const std::string& row);
54  void get_all_row_ids(std::vector<std::string>& ids) const;
55  void clear();
56 
58  return storage::version();
59  }
60 
61  void pack(framework::packer& packer) const;
62  void unpack(msgpack::object o);
63 
64  private:
68 
69  public:
70  MSGPACK_DEFINE(tbl_, column2id_);
71 };
72 
73 } // namespace storage
74 } // namespace core
75 } // namespace jubatus
76 
77 #endif // JUBATUS_CORE_STORAGE_SPARSE_MATRIX_STORAGE_HPP_
void set(const std::string &row, const std::string &column, float val)
void get_row(const std::string &row, std::vector< std::pair< std::string, float > > &columns) const
float calc_l2norm(const std::string &row) const
void pack(framework::packer &packer) const
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
sparse_matrix_storage & operator=(const sparse_matrix_storage &)
jubatus::util::data::unordered_map< std::string, row_t > tbl_t
void get_all_row_ids(std::vector< std::string > &ids) const
void set_row(const std::string &row, const std::vector< std::pair< std::string, float > > &columns)