jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
recommender_mock_storage.hpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2012 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_RECOMMENDER_RECOMMENDER_MOCK_STORAGE_HPP_
18 #define JUBATUS_CORE_RECOMMENDER_RECOMMENDER_MOCK_STORAGE_HPP_
19 
20 #include <map>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 #include <msgpack.hpp>
25 #include "../framework/mixable_helper.hpp"
26 #include "../common/version.hpp"
27 #include "recommender_type.hpp"
28 
29 namespace jubatus {
30 namespace core {
31 namespace recommender {
32 
34  public:
35  virtual ~recommender_mock_storage();
36 
37  void set_similar_items(
38  const common::sfv_t& query,
39  const std::vector<std::pair<std::string, float> >& ids);
40  void set_neighbor_items(
41  const common::sfv_t& query,
42  const std::vector<std::pair<std::string, float> >& ids);
43 
45  const common::sfv_t& query,
46  std::vector<std::pair<std::string, float> >& ids,
47  size_t ret_num) const;
49  const common::sfv_t& query,
50  std::vector<std::pair<std::string, float> >& ids,
51  size_t ret_num) const;
52 
53  void update(const common::sfv_t& from, const common::sfv_t& to);
54  void remove(const common::sfv_t& query);
55  void clear();
56 
57  std::string name() const;
58 
60  return storage::version();
61  }
62 
63  void pack(framework::packer& packer) const;
64  void unpack(msgpack::object o);
65 
66  void get_diff(recommender_mock_storage& diff) const;
67  bool put_diff(const recommender_mock_storage& mixed_diff);
69  const;
70 
71  private:
72  typedef std::map<common::sfv_t, std::vector<std::pair<std::string, float> > >
74 
75  static void get_relation(
76  const common::sfv_t& query,
77  const relation_type& relmap,
78  size_t ret_num,
79  std::vector<std::pair<std::string, float> >& ids);
80 
81  static void update_relation_key(
82  const common::sfv_t& from,
83  const common::sfv_t& to,
84  relation_type& relmap);
85 
86  static void mix_relation(const relation_type& from, relation_type& to);
87 
90 
91  public:
92  MSGPACK_DEFINE(similar_relation_, neighbor_relation_);
93 };
94 
96  recommender_mock_storage, recommender_mock_storage>
98 
99 } // namespace recommender
100 } // namespace core
101 } // namespace jubatus
102 
103 #endif // JUBATUS_CORE_RECOMMENDER_RECOMMENDER_MOCK_STORAGE_HPP_
MSGPACK_DEFINE(similar_relation_, neighbor_relation_)
void update(const common::sfv_t &from, const common::sfv_t &to)
static void get_relation(const common::sfv_t &query, const relation_type &relmap, size_t ret_num, std::vector< std::pair< std::string, float > > &ids)
void set_neighbor_items(const common::sfv_t &query, const std::vector< std::pair< std::string, float > > &ids)
void set_similar_items(const common::sfv_t &query, const std::vector< std::pair< std::string, float > > &ids)
bool put_diff(const recommender_mock_storage &mixed_diff)
static void update_relation_key(const common::sfv_t &from, const common::sfv_t &to, relation_type &relmap)
void similar_items_similarity(const common::sfv_t &query, std::vector< std::pair< std::string, float > > &ids, size_t ret_num) const
void mix(const recommender_mock_storage &lhs, recommender_mock_storage &rhs) const
void neighbor_items_distance(const common::sfv_t &query, std::vector< std::pair< std::string, float > > &ids, size_t ret_num) const
msgpack::packer< jubatus_packer > packer
Definition: bandit_base.hpp:31
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
static void mix_relation(const relation_type &from, relation_type &to)
std::map< common::sfv_t, std::vector< std::pair< std::string, float > > > relation_type
framework::linear_mixable_helper< recommender_mock_storage, recommender_mock_storage > mixable_recommender_mock_storage
void get_diff(recommender_mock_storage &diff) const