jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
bit_vector_nearest_neighbor_base.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_NEAREST_NEIGHBOR_BIT_VECTOR_NEAREST_NEIGHBOR_BASE_HPP_
18 #define JUBATUS_CORE_NEAREST_NEIGHBOR_BIT_VECTOR_NEAREST_NEIGHBOR_BASE_HPP_
19 
20 #include <map>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 #include "jubatus/util/lang/shared_ptr.h"
26 
27 namespace jubatus {
28 namespace core {
29 namespace storage {
30 class column_table;
31 }
32 namespace nearest_neighbor {
33 
35  public:
37  uint32_t bitnum,
38  jubatus::util::lang::shared_ptr<storage::column_table> table,
39  const std::string& id);
41  uint32_t bitnum,
42  jubatus::util::lang::shared_ptr<storage::column_table> table,
43  std::vector<storage::column_type>& schema,
44  const std::string& id);
45 
46  uint32_t bitnum() const { return bitnum_; }
47 
48  virtual void set_row(const std::string& id, const common::sfv_t& sfv);
49  virtual void neighbor_row(
50  const common::sfv_t& query,
51  std::vector<std::pair<std::string, float> >& ids,
52  uint64_t ret_num) const;
53  virtual void neighbor_row(
54  const std::string& query_id,
55  std::vector<std::pair<std::string, float> >& ids,
56  uint64_t ret_num) const;
57 
58  private:
59  virtual storage::bit_vector hash(const common::sfv_t& sfv) const = 0;
60 
61  void fill_schema(std::vector<storage::column_type>& schema);
63 
65  const storage::bit_vector& query,
66  std::vector<std::pair<std::string, float> >& ids,
67  uint64_t ret_num) const;
68 
70  uint32_t bitnum_;
71 };
72 
73 } // namespace nearest_neighbor
74 } // namespace core
75 } // namespace jubatus
76 
77 #endif // JUBATUS_CORE_NEAREST_NEIGHBOR_BIT_VECTOR_NEAREST_NEIGHBOR_BASE_HPP_
virtual void set_row(const std::string &id, const common::sfv_t &sfv)
void neighbor_row_from_hash(const storage::bit_vector &query, std::vector< std::pair< std::string, float > > &ids, uint64_t ret_num) const
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29
virtual storage::bit_vector hash(const common::sfv_t &sfv) const =0
virtual void neighbor_row(const common::sfv_t &query, std::vector< std::pair< std::string, float > > &ids, uint64_t ret_num) const
bit_vector_nearest_neighbor_base(uint32_t bitnum, jubatus::util::lang::shared_ptr< storage::column_table > table, const std::string &id)