jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
storage_factory.cpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2013 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 #include "storage_factory.hpp"
18 
19 #include <string>
20 #include "../common/exception.hpp"
21 #include "compressive_storage.hpp"
22 #include "gmm_compressor.hpp"
23 #include "kmeans_compressor.hpp"
24 #include "simple_storage.hpp"
25 
26 namespace jubatus {
27 namespace core {
28 namespace clustering {
29 
30 jubatus::util::lang::shared_ptr<storage> storage_factory::create(
31  const std::string& name,
32  const clustering_config& config) {
33  typedef jubatus::util::lang::shared_ptr<storage> ptr;
34  ptr ret;
35  if (config.compressor_method == "compressive_kmeans") {
36  compressive_storage *s = new compressive_storage(name, config);
37  s->set_compressor(jubatus::util::lang::shared_ptr<compressor::compressor>(
38  new compressor::kmeans_compressor(config)));
39  ret.reset(s);
40 #ifdef JUBATUS_USE_EIGEN
41  } else if (config.compressor_method == "compressive_gmm") {
42  compressive_storage *s = new compressive_storage(name, config);
43  s->set_compressor(jubatus::util::lang::shared_ptr<compressor::compressor>(
44  new compressor::gmm_compressor(config)));
45  ret.reset(s);
46 #endif
47  } else if (config.compressor_method == "simple") {
48  simple_storage *s = new simple_storage(name, config);
49  ret.reset(s);
50  } else {
51  throw JUBATUS_EXCEPTION(
53  }
54  return ret;
55 }
56 
57 } // namespace clustering
58 } // namespace core
59 } // namespace jubatus
#define JUBATUS_EXCEPTION(e)
Definition: exception.hpp:79
static jubatus::util::lang::shared_ptr< storage > create(const std::string &name, const clustering_config &config)
void set_compressor(jubatus::util::lang::shared_ptr< compressor::compressor > compressor)