ExecutionEngineImpl.h 2.0 KB
Newer Older
S
starlord 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/
#pragma once

#include "ExecutionEngine.h"
#include "wrapper/knowhere/vec_index.h"

#include <memory>
#include <string>

X
xj.lin 已提交
14

S
starlord 已提交
15 16 17 18 19 20
namespace zilliz {
namespace milvus {
namespace engine {


class ExecutionEngineImpl : public ExecutionEngine {
21
public:
S
starlord 已提交
22 23

    ExecutionEngineImpl(uint16_t dimension,
X
xj.lin 已提交
24 25 26 27 28 29
                        const std::string &location,
                        EngineType type);

    ExecutionEngineImpl(VecIndexPtr index,
                        const std::string &location,
                        EngineType type);
S
starlord 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42

    Status AddWithIds(long n, const float *xdata, const long *xids) override;

    size_t Count() const override;

    size_t Size() const override;

    size_t Dimension() const override;

    size_t PhysicalSize() const override;

    Status Serialize() override;

J
jinhai 已提交
43
    Status Load(bool to_cache) override;
S
starlord 已提交
44

45 46 47 48
    Status CopyToGpu(uint64_t device_id) override;

    Status CopyToCpu() override;

X
xj.lin 已提交
49
    Status Merge(const std::string &location) override;
S
starlord 已提交
50 51 52 53

    Status Search(long n,
                  const float *data,
                  long k,
Y
Yu Kun 已提交
54
                  long nprobe,
S
starlord 已提交
55 56 57
                  float *distances,
                  long *labels) const override;

X
xj.lin 已提交
58
    ExecutionEnginePtr BuildIndex(const std::string &) override;
S
starlord 已提交
59 60 61 62 63

    Status Cache() override;

    Status Init() override;

64
private:
X
xj.lin 已提交
65 66 67
    VecIndexPtr CreatetVecIndex(EngineType type);

    VecIndexPtr Load(const std::string &location);
S
starlord 已提交
68

69
protected:
X
xj.lin 已提交
70 71
    VecIndexPtr index_ = nullptr;
    EngineType build_type;
X
xj.lin 已提交
72
    EngineType current_type;
S
starlord 已提交
73

X
xj.lin 已提交
74
    int64_t dim;
S
starlord 已提交
75 76
    std::string location_;

X
xj.lin 已提交
77
    size_t nlist_ = 0;
X
xj.lin 已提交
78
    int64_t gpu_num = 0;
S
starlord 已提交
79 80 81 82 83 84
};


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