jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
nearest_neighbor_factory.cpp
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 
18 
19 #include <map>
20 #include <string>
21 
22 #include "../common/exception.hpp"
23 #include "../common/jsonconfig.hpp"
24 #include "nearest_neighbor.hpp"
25 
26 using jubatus::util::lang::shared_ptr;
27 
28 namespace jubatus {
29 namespace core {
30 namespace nearest_neighbor {
31 
32 shared_ptr<nearest_neighbor_base> create_nearest_neighbor(
33  const std::string& name,
34  const common::jsonconfig::config& config,
35  shared_ptr<storage::column_table> table,
36  const std::string& id) {
37 
39 
40  if (name == "euclid_lsh") {
41  return shared_ptr<nearest_neighbor_base>(
42  new euclid_lsh(config_cast_check<euclid_lsh::config>(config),
43  table,
44  id));
45  } else if (name == "lsh") {
46  return shared_ptr<nearest_neighbor_base>(
47  new lsh(config_cast_check<lsh::config>(config), table, id));
48  } else if (name == "minhash") {
49  return shared_ptr<nearest_neighbor_base>(
50  new minhash(config_cast_check<minhash::config>(config), table, id));
51  } else {
53  }
54 }
55 
56 } // namespace nearest_neighbor
57 } // namespace core
58 } // namespace jubatus
T config_cast_check(const config &c)
Definition: cast.hpp:311
#define JUBATUS_EXCEPTION(e)
Definition: exception.hpp:79
shared_ptr< nearest_neighbor_base > create_nearest_neighbor(const std::string &name, const common::jsonconfig::config &config, shared_ptr< storage::column_table > table, const std::string &id)