jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
storage_base.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_STORAGE_BASE_HPP_
18 #define JUBATUS_CORE_STORAGE_STORAGE_BASE_HPP_
19 
20 #include <map>
21 #include <string>
22 #include <utility>
23 #include <stdexcept>
24 #include <vector>
25 #include "jubatus/util/concurrent/mutex.h"
26 #include "jubatus/util/lang/shared_ptr.h"
27 #include "storage_type.hpp"
28 #include "storage_exception.hpp"
29 #include "../common/version.hpp"
30 #include "../common/exception.hpp"
31 #include "../common/type.hpp"
32 #include "../framework/model.hpp"
33 
34 namespace jubatus {
35 namespace core {
36 namespace storage {
37 
39  public:
40  virtual ~storage_base() {
41  }
42 
43  virtual void get(const std::string& feature, feature_val1_t& ret) const = 0;
44  virtual void get_nolock(const std::string& feature,
45  feature_val1_t& ret) const = 0;
46  virtual void get2(const std::string& feature, feature_val2_t& ret) const = 0;
47  virtual void get2_nolock(const std::string& feature,
48  feature_val2_t& ret) const = 0;
49  virtual void get3(const std::string& feature, feature_val3_t& ret) const = 0;
50  virtual void get3_nolock(const std::string& feature,
51  feature_val3_t& ret) const = 0;
52 
53  // inner product
54  virtual void inp(const common::sfv_t& sfv, map_feature_val1_t& ret) const = 0;
55 
56  virtual void set(
57  const std::string& feature,
58  const std::string& klass,
59  const val1_t& w) = 0;
60  virtual void set_nolock(
61  const std::string& feature,
62  const std::string& klass,
63  const val1_t& w) = 0;
64  virtual void set2(
65  const std::string& feature,
66  const std::string& klass,
67  const val2_t& w) = 0;
68  virtual void set2_nolock(
69  const std::string& feature,
70  const std::string& klass,
71  const val2_t& w) = 0;
72  virtual void set3(
73  const std::string& feature,
74  const std::string& klass,
75  const val3_t& w) = 0;
76  virtual void set3_nolock(
77  const std::string& feature,
78  const std::string& klass,
79  const val3_t& w) = 0;
80 
81  virtual void get_status(std::map<std::string, std::string>&) const = 0;
82 
83  virtual void pack(framework::packer& packer) const = 0;
84  virtual void unpack(msgpack::object o) = 0;
85 
86  virtual version get_version() const = 0;
87 
88  virtual void update(
89  const std::string& feature,
90  const std::string& inc_class,
91  const std::string& dec_class,
92  const val1_t& w);
93 
94  virtual void bulk_update(
95  const common::sfv_t& sfv,
96  float step_width,
97  const std::string& inc_class,
98  const std::string& dec_class);
99 
100  virtual util::concurrent::mutex& get_lock() const = 0;
101 
102  virtual void get_diff(diff_t&) const;
103  virtual bool set_average_and_clear_diff(const diff_t&);
104 
105  virtual void register_label(const std::string& label) = 0;
106 
107  virtual void clear() = 0;
108 
109  virtual std::vector<std::string> get_labels() const = 0;
110  virtual bool set_label(const std::string& label) = 0;
111  virtual bool delete_label(const std::string& label) = 0;
112  virtual bool delete_label_nolock(const std::string& label) = 0;
113 
114  virtual std::string type() const = 0;
115 };
116 
117 } // namespace storage
118 
119 typedef jubatus::util::lang::shared_ptr<jubatus::core::storage::storage_base>
121 
122 } // namespace core
123 } // namespace jubatus
124 
125 #endif // JUBATUS_CORE_STORAGE_STORAGE_BASE_HPP_
jubatus::util::lang::shared_ptr< jubatus::core::storage::storage_base > storage_ptr
virtual void set_nolock(const std::string &feature, const std::string &klass, const val1_t &w)=0
virtual void get_status(std::map< std::string, std::string > &) const =0
virtual void pack(framework::packer &packer) const =0
virtual void inp(const common::sfv_t &sfv, map_feature_val1_t &ret) const =0
virtual util::concurrent::mutex & get_lock() const =0
virtual bool set_average_and_clear_diff(const diff_t &)
virtual void register_label(const std::string &label)=0
jubatus::util::data::unordered_map< std::string, val1_t > map_feature_val1_t
virtual void set3(const std::string &feature, const std::string &klass, const val3_t &w)=0
virtual void unpack(msgpack::object o)=0
virtual void update(const std::string &feature, const std::string &inc_class, const std::string &dec_class, const val1_t &w)
virtual void get_diff(diff_t &) const
virtual void get2_nolock(const std::string &feature, feature_val2_t &ret) const =0
virtual bool delete_label_nolock(const std::string &label)=0
virtual void bulk_update(const common::sfv_t &sfv, float step_width, const std::string &inc_class, const std::string &dec_class)
virtual void get_nolock(const std::string &feature, feature_val1_t &ret) const =0
std::vector< std::pair< std::string, val1_t > > feature_val1_t
virtual bool delete_label(const std::string &label)=0
virtual version get_version() const =0
virtual void get3(const std::string &feature, feature_val3_t &ret) const =0
virtual std::vector< std::string > get_labels() const =0
virtual void get2(const std::string &feature, feature_val2_t &ret) const =0
virtual void set2_nolock(const std::string &feature, const std::string &klass, const val2_t &w)=0
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
virtual void get3_nolock(const std::string &feature, feature_val3_t &ret) const =0
std::vector< std::pair< std::string, val3_t > > feature_val3_t
virtual std::string type() const =0
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
virtual void set(const std::string &feature, const std::string &klass, const val1_t &w)=0
virtual bool set_label(const std::string &label)=0
std::vector< std::pair< std::string, val2_t > > feature_val2_t
virtual void set3_nolock(const std::string &feature, const std::string &klass, const val3_t &w)=0
virtual void set2(const std::string &feature, const std::string &klass, const val2_t &w)=0