17 #ifndef JUBATUS_CORE_ANOMALY_LOF_STORAGE_HPP_
18 #define JUBATUS_CORE_ANOMALY_LOF_STORAGE_HPP_
25 #include <msgpack.hpp>
26 #include "jubatus/util/data/serialization.h"
27 #include "jubatus/util/data/unordered_map.h"
28 #include "jubatus/util/data/unordered_set.h"
29 #include "jubatus/util/lang/shared_ptr.h"
30 #include "jubatus/util/text/json.h"
32 #include "../common/type.hpp"
33 #include "../common/unordered_map.hpp"
34 #include "../framework/mixable_helper.hpp"
38 namespace recommender {
50 typedef jubatus::util::data::unordered_map<std::string, lof_entry>
lof_table_t;
66 & JUBA_MEMBER(nearest_neighbor_num)
67 & JUBA_MEMBER(reverse_nearest_neighbor_num);
73 jubatus::util::lang::shared_ptr<core::recommender::recommender_base>
79 jubatus::util::lang::shared_ptr<core::recommender::recommender_base>
88 jubatus::util::data::unordered_map<std::string, float>&
91 const std::string&
id,
92 jubatus::util::data::unordered_map<std::string, float>&
103 std::string
name()
const;
106 float get_kdist(
const std::string& row)
const;
107 float get_lrd(
const std::string& row)
const;
109 bool has_row(
const std::string& row)
const;
113 jubatus::util::lang::shared_ptr<core::recommender::recommender_base>
116 void get_diff(lof_table_t& diff)
const;
117 bool put_diff(
const lof_table_t& mixed_diff);
118 void mix(
const lof_table_t& lhs, lof_table_t& rhs)
const;
138 const std::vector<std::pair<std::string, float> >& neighbors,
139 jubatus::util::data::unordered_map<std::string, float>&
143 const std::string& row,
144 jubatus::util::data::unordered_set<std::string>& nn)
const;
147 const jubatus::util::data::unordered_set<std::string>& rows);
152 const std::string& row,
153 const std::vector<std::pair<std::string, float> >& neighbors);
155 const std::string& row,
156 const std::vector<std::pair<std::string, float> >& neighbors);
164 jubatus::util::lang::shared_ptr<core::recommender::recommender_base>
175 #endif // JUBATUS_CORE_ANOMALY_LOF_STORAGE_HPP_
static bool is_removed(const lof_entry &entry)
float get_kdist(const std::string &row) const
MSGPACK_DEFINE(kdist, lrd)
void update_row(const std::string &row, const common::sfv_t &diff)
void mix(const lof_table_t &lhs, lof_table_t &rhs) const
float get_lrd(const std::string &row) const
static const uint32_t DEFAULT_NEIGHBOR_NUM
MSGPACK_DEFINE(lof_table_, lof_table_diff_, neighbor_num_, reverse_nn_num_)
void update_kdist(const std::string &row)
static const uint32_t DEFAULT_REVERSE_NN_NUM
jubatus::util::lang::shared_ptr< core::recommender::recommender_base > nn_engine_
int reverse_nearest_neighbor_num
void update_lrd_with_neighbors(const std::string &row, const std::vector< std::pair< std::string, float > > &neighbors)
lof_table_t lof_table_diff_
void get_diff(lof_table_t &diff) const
void update_entries(const jubatus::util::data::unordered_set< std::string > &rows)
bool put_diff(const lof_table_t &mixed_diff)
void pack(framework::packer &packer) const
msgpack::packer< jubatus_packer > packer
void get_all_row_ids(std::vector< std::string > &ids) const
framework::linear_mixable_helper< lof_storage, lof_table_t > mixable_lof_storage
void unpack(msgpack::object o)
void set_nn_engine(jubatus::util::lang::shared_ptr< core::recommender::recommender_base > nn_engine)
void collect_neighbors(const std::string &row, jubatus::util::data::unordered_set< std::string > &nn) const
static void mark_removed(lof_entry &entry)
float collect_lrds(const common::sfv_t &query, jubatus::util::data::unordered_map< std::string, float > &neighbor_lrd) const
std::vector< std::pair< std::string, float > > sfv_t
storage::version get_version() const
void remove_row(const std::string &row)
bool has_row(const std::string &row) const
void update_kdist_with_neighbors(const std::string &row, const std::vector< std::pair< std::string, float > > &neighbors)
void update_lrd(const std::string &row)
jubatus::util::data::unordered_map< std::string, lof_entry > lof_table_t
float collect_lrds_from_neighbors(const std::vector< std::pair< std::string, float > > &neighbors, jubatus::util::data::unordered_map< std::string, float > &neighbor_lrd) const