NewMemManager.h 1.5 KB
Newer Older
Z
zhiru 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
#pragma once

#include "Meta.h"
#include "MemTable.h"
#include "Status.h"
#include "MemManagerAbstract.h"

#include <map>
#include <string>
#include <ctime>
#include <memory>
#include <mutex>

Z
update  
zhiru 已提交
14

Z
zhiru 已提交
15 16 17 18 19
namespace zilliz {
namespace milvus {
namespace engine {

class NewMemManager : public MemManagerAbstract {
Z
update  
zhiru 已提交
20
 public:
Z
zhiru 已提交
21 22 23 24
    using MetaPtr = meta::Meta::Ptr;
    using Ptr = std::shared_ptr<NewMemManager>;
    using MemTablePtr = typename MemTable::Ptr;

Z
update  
zhiru 已提交
25 26
    NewMemManager(const std::shared_ptr<meta::Meta> &meta, const Options &options)
        : meta_(meta), options_(options) {}
Z
zhiru 已提交
27

Z
update  
zhiru 已提交
28 29
    Status InsertVectors(const std::string &table_id,
                         size_t n, const float *vectors, IDNumbers &vector_ids) override;
Z
zhiru 已提交
30

Z
update  
zhiru 已提交
31
    Status Serialize(std::set<std::string> &table_ids) override;
Z
zhiru 已提交
32

Z
update  
zhiru 已提交
33
    Status EraseMemVector(const std::string &table_id) override;
Z
zhiru 已提交
34

Z
zhiru 已提交
35 36 37 38 39 40
    size_t GetCurrentMutableMem() override;

    size_t GetCurrentImmutableMem() override;

    size_t GetCurrentMem() override;

Z
update  
zhiru 已提交
41 42
 private:
    MemTablePtr GetMemByTable(const std::string &table_id);
Z
zhiru 已提交
43

Z
update  
zhiru 已提交
44 45
    Status InsertVectorsNoLock(const std::string &table_id,
                               size_t n, const float *vectors, IDNumbers &vector_ids);
Z
zhiru 已提交
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    Status ToImmutable();

    using MemIdMap = std::map<std::string, MemTablePtr>;
    using MemList = std::vector<MemTablePtr>;
    MemIdMap mem_id_map_;
    MemList immu_mem_list_;
    MetaPtr meta_;
    Options options_;
    std::mutex mutex_;
    std::mutex serialization_mtx_;
}; // NewMemManager


} // namespace engine
} // namespace milvus
} // namespace zilliz