jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
lsh_util.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_STORAGE_LSH_UTIL_HPP_
18 #define JUBATUS_CORE_STORAGE_LSH_UTIL_HPP_
19 
20 #include <functional>
21 #include <queue>
22 #include <utility>
23 #include <vector>
24 #include "lsh_vector.hpp"
25 
26 namespace jubatus {
27 namespace core {
28 namespace storage {
29 
31  public:
32  lsh_probe_generator(const std::vector<float>& hash, size_t num_hash_tables);
33 
34  void init();
35 
36  lsh_vector base_all() const;
37  const lsh_vector& base(size_t i) const {
38  return base_[i];
39  }
40  std::pair<size_t, lsh_vector> get_next_table_and_vector();
41 
42  private:
43  typedef std::pair<float, std::pair<size_t, std::vector<int> > > diff_type;
44  typedef std::priority_queue<
45  diff_type,
46  std::vector<diff_type>,
47  std::greater<diff_type> > heap_type;
48 
49  void next_perturbations();
50 
51  std::vector<std::vector<float> > hash_;
52  std::vector<lsh_vector> base_;
53  std::vector<std::vector<std::pair<float, int> > > perturbation_sets_;
54  heap_type heap_;
55 };
56 
57 } // namespace storage
58 } // namespace core
59 } // namespace jubatus
60 
61 #endif // JUBATUS_CORE_STORAGE_LSH_UTIL_HPP_
lsh_probe_generator(const std::vector< float > &hash, size_t num_hash_tables)
Definition: lsh_util.cpp:84
std::pair< size_t, lsh_vector > get_next_table_and_vector()
Definition: lsh_util.cpp:129
std::vector< std::vector< float > > hash_
Definition: lsh_util.hpp:51
std::vector< std::vector< std::pair< float, int > > > perturbation_sets_
Definition: lsh_util.hpp:53
const lsh_vector & base(size_t i) const
Definition: lsh_util.hpp:37
std::pair< float, std::pair< size_t, std::vector< int > > > diff_type
Definition: lsh_util.hpp:43
std::priority_queue< diff_type, std::vector< diff_type >, std::greater< diff_type > > heap_type
Definition: lsh_util.hpp:47