提交 b162ab0a 编写于 作者: X Xu Peng

fix(db): fix compile error


Former-commit-id: d6d70bd6a6607001e90b920726c62af48b5341f5
上级 5c5e3205
#include <IndexFlat.h>
#include <MetaIndexes.h>
#include <index_io.h>
#include <faiss/IndexFlat.h>
#include <faiss/MetaIndexes.h>
#include <faiss/index_io.h>
#include "memvectors.h"
#include "db_meta.h"
namespace vecengine {
namespace zilliz {
namespace vecwise {
namespace engine {
MemVectors::MemVectors(size_t dimension_, const std::string& file_location_) :
_file_location(file_location_),
_file_location(file_location_.c_str()),
_pIdGenerator(new SimpleIDGenerator()),
_dimension(dimension_),
_pInnerIndex(new faiss::IndexFlat(_dimension)),
_pIdMapIndex = new faiss::IndexIDMap(_pInnerIndex) {
_pIdMapIndex(new faiss::IndexIDMap(_pInnerIndex)) {
}
void MemVectors::add(size_t n_, const float* vectors_, IDNumbers& vector_ids_) {
......@@ -52,14 +54,14 @@ MemVectors::~MemVectors() {
* MemManager
*/
VectorsPtr MemManager::get_mem_by_group(const std::string& group_id_) {
auto memIt = _memMap.find(group_id_);
if memIt != _memMap.end() {
return &(memIt->second);
VectorsPtr MemManager::get_mem_by_group(const std::string& group_id) {
auto memIt = _memMap.find(group_id);
if (memIt != _memMap.end()) {
return memIt->second;
}
GroupSchema group_info;
Status status = _pMeta->get_group(group_id_, group_info);
Status status = _pMeta->get_group(group_id, group_info);
if (!status.ok()) {
return nullptr;
}
......@@ -76,15 +78,17 @@ Status MemManager::add_vectors(const std::string& group_id_,
return add_vectors_no_lock(group_id_, n_, vectors_, vector_ids_);
}
Status MemManager::add_vectors_no_lock(const std::string& group_id_,
Status MemManager::add_vectors_no_lock(const std::string& group_id,
size_t n,
const float* vectors,
IDNumbers& vector_ids_) {
auto mem = get_mem_by_group(group_id_);
IDNumbers& vector_ids) {
auto mem = get_mem_by_group(group_id);
if (mem == nullptr) {
return Status::NotFound("Group " + group_id_ " not found!");
return Status::NotFound("Group " + group_id + " not found!");
}
return mem->add(n, vectors, vector_ids_);
mem->add(n, vectors, vector_ids);
return Status::OK();
}
Status MemManager::mark_memory_as_immutable() {
......@@ -111,11 +115,13 @@ Status MemManager::mark_memory_as_immutable() {
Status MemManager::serialize() {
mark_memory_as_immutable();
for (auto& mem : _immMems) {
mem->serialize()
mem->serialize();
}
_immMems.clear();
/* _last_compact_time = std::time(nullptr); */
}
} // namespace vecengine
} // namespace engine
} // namespace vecwise
} // namespace zilliz
......@@ -4,6 +4,8 @@
#include <map>
#include <string>
#include <ctime>
#include <memory>
#include <mutex>
#include "id_generators.h"
#include "status.h"
......@@ -21,7 +23,7 @@ class MemVectors {
public:
explicit MemVectors(size_t dimension_, const std::string& file_location_);
IDNumbers&& add(size_t n, const float* vectors);
void add(size_t n_, const float* vectors_, IDNumbers& vector_ids_);
size_t total() const;
......@@ -32,7 +34,7 @@ public:
~MemVectors();
private:
std::string _file_location;
const char* _file_location;
IDGenerator* _pIdGenerator;
size_t _dimension;
faiss::Index* _pInnerIndex;
......@@ -42,10 +44,10 @@ private:
class Meta;
typedef std::shared_ptr<MemVectors> VectorsPtr;
class MemManager {
public:
typedef std::shared_ptr<MemVectors> VectorsPtr;
MemManager(const std::shared_ptr<Meta>& meta_)
: _pMeta(meta_), _last_compact_time(std::time(nullptr)) {}
......@@ -59,6 +61,7 @@ public:
private:
Status add_vectors_no_lock(const std::string& group_id_,
size_t n_, const float* vectors_, IDNumbers& vector_ids_);
Status mark_memory_as_immutable();
typedef std::map<std::string, VectorsPtr> MemMap;
typedef std::vector<VectorsPtr> ImmMemPool;
......
#include "options.h"
#include "env.h"
namespace zilliz {
namespace vecwise {
......
#ifndef VECENGINE_OPTIONS_H_
#define VECENGINE_OPTIONS_H_
#pragma once
#include <string>
#include <memory>
......@@ -12,6 +11,7 @@ class MetaOptions;
class Env;
struct Options {
Options();
uint16_t memory_sync_interval = 10;
uint16_t raw_file_merge_trigger_number = 100;
size_t raw_to_index_trigger_size = 100000;
......@@ -39,5 +39,3 @@ struct DBMetaOptions : public MetaOptions {
} // namespace engine
} // namespace vecwise
} // namespace zilliz
#endif // VECENGINE_OPTIONS_H_
......@@ -6,7 +6,7 @@ namespace zilliz {
namespace vecwise {
namespace engine {
typedef uint64_t IDNumber;
typedef long IDNumber;
typedef IDNumber* IDNumberPtr;
typedef std::vector<IDNumber> IDNumbers;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册