ExecutionEngineImpl.h 2.4 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
                        const std::string &location,
S
starlord 已提交
25 26 27
                        EngineType index_type,
                        MetricType metric_type,
                        int32_t nlist);
X
xj.lin 已提交
28 29 30

    ExecutionEngineImpl(VecIndexPtr index,
                        const std::string &location,
S
starlord 已提交
31 32 33
                        EngineType index_type,
                        MetricType metric_type,
                        int32_t nlist);
S
starlord 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46

    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 已提交
47
    Status Load(bool to_cache) override;
S
starlord 已提交
48

49 50 51 52
    Status CopyToGpu(uint64_t device_id) override;

    Status CopyToCpu() override;

X
xj.lin 已提交
53
    Status Merge(const std::string &location) override;
S
starlord 已提交
54 55 56 57

    Status Search(long n,
                  const float *data,
                  long k,
Y
Yu Kun 已提交
58
                  long nprobe,
S
starlord 已提交
59 60 61
                  float *distances,
                  long *labels) const override;

X
xj.lin 已提交
62
    ExecutionEnginePtr BuildIndex(const std::string &) override;
S
starlord 已提交
63 64 65

    Status Cache() override;

Y
Yu Kun 已提交
66 67
    Status GpuCache(uint64_t gpu_id) override;

S
starlord 已提交
68 69
    Status Init() override;

S
starlord 已提交
70 71 72 73
    EngineType IndexEngineType() const override { return index_type_; }

    MetricType IndexMetricType() const override { return metric_type_; }

74
private:
X
xj.lin 已提交
75 76 77
    VecIndexPtr CreatetVecIndex(EngineType type);

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

79
protected:
X
xj.lin 已提交
80
    VecIndexPtr index_ = nullptr;
S
starlord 已提交
81 82
    EngineType index_type_;
    MetricType metric_type_;
S
starlord 已提交
83

S
starlord 已提交
84
    int64_t dim_;
S
starlord 已提交
85 86
    std::string location_;

S
starlord 已提交
87 88
    int32_t nlist_ = 0;
    int64_t gpu_num_ = 0;
S
starlord 已提交
89 90 91 92 93 94
};


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