ExecutionEngine.h 1.7 KB
Newer Older
X
Xu Peng 已提交
1 2 3 4 5
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/
X
Xu Peng 已提交
6 7
#pragma once

S
starlord 已提交
8
#include "db/Status.h"
9

X
Xu Peng 已提交
10
#include <vector>
X
Xu Peng 已提交
11
#include <memory>
X
Xu Peng 已提交
12 13

namespace zilliz {
J
jinhai 已提交
14
namespace milvus {
X
Xu Peng 已提交
15 16
namespace engine {

G
groot 已提交
17
enum class EngineType {
G
groot 已提交
18
    INVALID = 0,
G
groot 已提交
19 20
    FAISS_IDMAP = 1,
    FAISS_IVFFLAT,
S
starlord 已提交
21
    FAISS_IVFSQ8,
X
xj.lin 已提交
22
    NSG_MIX,
X
xj.lin 已提交
23
    MAX_VALUE = NSG_MIX,
G
groot 已提交
24 25
};

26
class ExecutionEngine {
27 28
public:

G
groot 已提交
29
    virtual Status AddWithIdArray(const std::vector<float>& vectors, const std::vector<long>& vector_ids);
30

G
groot 已提交
31
    virtual Status AddWithIds(long n, const float *xdata, const long *xids) = 0;
32

G
groot 已提交
33
    virtual size_t Count() const = 0;
34

G
groot 已提交
35
    virtual size_t Size() const = 0;
36

G
groot 已提交
37 38
    virtual size_t Dimension() const = 0;

G
groot 已提交
39
    virtual size_t PhysicalSize() const = 0;
40

G
groot 已提交
41
    virtual Status Serialize() = 0;
42

S
starlord 已提交
43
    virtual Status Load(bool to_cache = true) = 0;
44

45 46 47 48
    virtual Status CopyToGpu(uint64_t device_id) = 0;

    virtual Status CopyToCpu() = 0;

G
groot 已提交
49
    virtual Status Merge(const std::string& location) = 0;
50

G
groot 已提交
51
    virtual Status Search(long n,
52 53
                  const float *data,
                  long k,
Y
Yu Kun 已提交
54
                  long nprobe,
55
                  float *distances,
G
groot 已提交
56
                  long *labels) const = 0;
57

G
groot 已提交
58
    virtual std::shared_ptr<ExecutionEngine> BuildIndex(const std::string&) = 0;
59

G
groot 已提交
60
    virtual Status Cache() = 0;
Y
yu yunfeng 已提交
61 62

    virtual Status Init() = 0;
63 64
};

G
groot 已提交
65 66
using ExecutionEnginePtr = std::shared_ptr<ExecutionEngine>;

X
Xu Peng 已提交
67 68

} // namespace engine
J
jinhai 已提交
69
} // namespace milvus
X
Xu Peng 已提交
70
} // namespace zilliz