jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
lsh.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_LSH_HPP_
18 #define JUBATUS_CORE_NEAREST_NEIGHBOR_LSH_HPP_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 #include "jubatus/util/data/serialization.h"
24 #include "jubatus/util/lang/shared_ptr.h"
26 
27 namespace jubatus {
28 namespace core {
29 namespace storage {
30 class column_table;
31 } // namespace storage
32 namespace nearest_neighbor {
33 
35  public:
36  struct config {
37  config() : hash_num(64u) {
38  }
39 
40  int32_t hash_num;
41 
42  template <typename Ar>
43  void serialize(Ar& ar) {
44  ar & JUBA_MEMBER(hash_num);
45  }
46  };
47  lsh(const config& conf,
48  jubatus::util::lang::shared_ptr<storage::column_table> table,
49  const std::string& id);
50  lsh(const config& conf,
51  jubatus::util::lang::shared_ptr<storage::column_table> table,
52  std::vector<storage::column_type>& schema,
53  const std::string& id);
54 
55  virtual std::string type() const { return "lsh"; }
56 
57  private:
58  virtual storage::bit_vector hash(const common::sfv_t& sfv) const;
59 };
60 
61 } // namespace nearest_neighbor
62 } // namespace core
63 } // namespace jubatus
64 
65 #endif // JUBATUS_CORE_NEAREST_NEIGHBOR_LSH_HPP_
virtual std::string type() const
Definition: lsh.hpp:55
virtual storage::bit_vector hash(const common::sfv_t &sfv) const
Definition: lsh.cpp:53
lsh(const config &conf, jubatus::util::lang::shared_ptr< storage::column_table > table, const std::string &id)
Definition: lsh.cpp:28
std::vector< std::pair< std::string, float > > sfv_t
Definition: type.hpp:29