jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
local_storage_mixture.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_LOCAL_STORAGE_MIXTURE_HPP_
18 #define JUBATUS_CORE_STORAGE_LOCAL_STORAGE_MIXTURE_HPP_
19 
20 #include <stdint.h>
21 #include <map>
22 #include <string>
23 #include <vector>
24 #include "jubatus/util/concurrent/mutex.h"
25 #include "jubatus/util/data/intern.h"
26 #include "local_storage.hpp"
27 #include "../common/version.hpp"
28 
29 namespace jubatus {
30 namespace core {
31 namespace storage {
32 
34  public:
37 
38  void get(const std::string& feature, feature_val1_t& ret) const;
39  void get_nolock(const std::string& feature, feature_val1_t& ret) const;
40  void get2(const std::string& feature, feature_val2_t& ret) const;
41  void get2_nolock(const std::string& feature, feature_val2_t& ret) const;
42  void get3(const std::string& feature, feature_val3_t& ret) const;
43  void get3_nolock(const std::string& feature, feature_val3_t& ret) const;
44 
46  void inp(const common::sfv_t& sfv, map_feature_val1_t& ret) const;
47 
48  void get_diff(diff_t& ret) const;
49  bool set_average_and_clear_diff(const diff_t& average);
50 
51  void set(
52  const std::string& feature,
53  const std::string& klass,
54  const val1_t& w);
55  void set_nolock(
56  const std::string& feature,
57  const std::string& klass,
58  const val1_t& w);
59  void set2(
60  const std::string& feature,
61  const std::string& klass,
62  const val2_t& w);
63  void set2_nolock(
64  const std::string& feature,
65  const std::string& klass,
66  const val2_t& w);
67  void set3(
68  const std::string& feature,
69  const std::string& klass,
70  const val3_t& w);
71  void set3_nolock(
72  const std::string& feature,
73  const std::string& klass,
74  const val3_t& w);
75 
76  void get_status(std::map<std::string, std::string>& status) const;
77 
78  void update(
79  const std::string& feature,
80  const std::string& inc_class,
81  const std::string& dec_class,
82  const val1_t& v);
83 
84  void bulk_update(
85  const common::sfv_t& sfv,
86  float step_width,
87  const std::string& inc_class,
88  const std::string& dec_class);
89 
90  util::concurrent::mutex& get_lock() const {
91  return mutex_;
92  }
93 
94  void register_label(const std::string& label);
95  bool delete_label(const std::string& label);
96  bool delete_label_nolock(const std::string& label);
97 
98  void clear();
99  std::vector<std::string> get_labels() const;
100  bool set_label(const std::string& label);
101 
102  void pack(framework::packer& packer) const;
103  void unpack(msgpack::object o);
104 
106  return model_version_;
107  }
108 
109  std::string type() const;
110 
112 
113  private:
114  bool get_internal(const std::string& feature, id_feature_val3_t& ret) const;
115 
116  mutable util::concurrent::mutex mutex_;
121 };
122 
123 } // namespace storage
124 } // namespace core
125 } // namespace jubatus
126 
127 #endif // JUBATUS_CORE_STORAGE_LOCAL_STORAGE_MIXTURE_HPP_
void set3_nolock(const std::string &feature, const std::string &klass, const val3_t &w)
void update(const std::string &feature, const std::string &inc_class, const std::string &dec_class, const val1_t &v)
void get2_nolock(const std::string &feature, feature_val2_t &ret) const
void set(const std::string &feature, const std::string &klass, const val1_t &w)
bool get_internal(const std::string &feature, id_feature_val3_t &ret) const
void inp(const common::sfv_t &sfv, map_feature_val1_t &ret) const
inner product
void get3(const std::string &feature, feature_val3_t &ret) const
jubatus::util::data::unordered_map< std::string, val1_t > map_feature_val1_t
void get3_nolock(const std::string &feature, feature_val3_t &ret) const
MSGPACK_DEFINE(tbl_, class2id_, tbl_diff_, model_version_)
jubatus::util::data::unordered_map< std::string, id_feature_val3_t > id_features3_t
void set3(const std::string &feature, const std::string &klass, const val3_t &w)
std::vector< std::pair< std::string, val1_t > > feature_val1_t
std::vector< std::string > get_labels() const
void get_nolock(const std::string &feature, feature_val1_t &ret) const
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
std::vector< T > v(size)
void pack(framework::packer &packer) const
void get_status(std::map< std::string, std::string > &status) const
void get2(const std::string &feature, feature_val2_t &ret) const
void set_nolock(const std::string &feature, const std::string &klass, const val1_t &w)
std::vector< std::pair< std::string, val3_t > > feature_val3_t
void set2(const std::string &feature, const std::string &klass, const val2_t &w)
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
jubatus::util::data::unordered_map< uint64_t, val3_t > id_feature_val3_t
std::vector< std::pair< std::string, val2_t > > feature_val2_t
void set2_nolock(const std::string &feature, const std::string &klass, const val2_t &w)
void bulk_update(const common::sfv_t &sfv, float step_width, const std::string &inc_class, const std::string &dec_class)