-
Notifications
You must be signed in to change notification settings - Fork 1
/
convchecker_serv.cpp
106 lines (83 loc) · 2.36 KB
/
convchecker_serv.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// this is automatically generated template header please implement and edit.
#include <sstream>
#include "convchecker_serv.hpp"
#include <jubatus/common/shared_ptr.hpp>
#include <jubatus/fv_converter/datum.hpp>
#include <jubatus/fv_converter/datum_to_fv_converter.hpp>
#include <jubatus/framework/mixer/mixer_factory.hpp>
using namespace jubatus::common;
using namespace jubatus::framework;
using namespace pfi::lang;
namespace jubatus { namespace server { // do not change
convchecker_serv::convchecker_serv(const server_argv& a, const jubatus::common::cshared_ptr<jubatus::common::lock_service>& zk)
:server_base(a)
{
mixer_.reset(mixer::create_mixer(a, zk));
}
convchecker_serv::~convchecker_serv()
{}
//update, broadcast
bool convchecker_serv::set_config(const config_data& c)
{
shared_ptr<jubatus::fv_converter::datum_to_fv_converter> converter = framework::make_fv_converter(c.config);
config_ = c;
converter_ = converter;
return true;
}
//analysis, random
config_data convchecker_serv::get_config() const
{
check_set_config();
return config_;
}
//update, random
std::string convchecker_serv::query(const jubatus::datum& query)
{
jubatus::sfv_t fv;
fv_converter::datum d;
check_set_config();
convert<jubatus::datum, fv_converter::datum>(query, d);
converter_->convert(d, fv);
std::stringstream ret;
for (size_t i = 0; i < fv.size(); ++i) {
ret << fv[i].first << ": " << fv[i].second << std::endl;
}
return ret.str();
}
//update, random
std::string convchecker_serv::bulk_query(const std::vector<datum >& query)
{
jubatus::sfv_t fv;
fv_converter::datum d;
std::stringstream ret;
check_set_config();
for (size_t i = 0; i < query.size(); ++i) {
convert<jubatus::datum, fv_converter::datum>(query[i], d);
converter_->convert(d, fv);
for (size_t i = 0; i < fv.size(); ++i) {
ret << fv[i].first << ": " << fv[i].second << std::endl;
}
}
return ret.str();
}
//update, broadcast
bool convchecker_serv::save(const std::string& id)
{
return false;
}
//update, broadcast
bool convchecker_serv::load(const std::string& id)
{
return false;
}
//analysis, broadcast
void convchecker_serv::get_status(status_t& status) const
{}
void convchecker_serv::check_set_config()const
{
if (!converter_){
throw JUBATUS_EXCEPTION(config_not_set());
}
}
void convchecker_serv::after_load(){}
}} // namespace jubatus::serve