ExecutionEngine.h 1.7 KB
Newer Older
X
Xu Peng 已提交
1 2 3
#pragma once

#include <vector>
X
Xu Peng 已提交
4
#include <memory>
X
Xu Peng 已提交
5

X
Xu Peng 已提交
6 7
#include "Status.h"

X
Xu Peng 已提交
8 9 10 11
namespace zilliz {
namespace vecwise {
namespace engine {

X
Xu Peng 已提交
12 13
class ExecutionEngine;

X
Xu Peng 已提交
14
class ExecutionEngine {
X
Xu Peng 已提交
15 16
public:

X
Xu Peng 已提交
17
    Status AddWithIds(const std::vector<float>& vectors,
X
Xu Peng 已提交
18 19
                              const std::vector<long>& vector_ids);

X
Xu Peng 已提交
20 21 22 23 24 25
    virtual Status AddWithIds(long n, const float *xdata, const long *xids) = 0;

    virtual size_t Count() const = 0;

    virtual size_t Size() const = 0;

26 27
    virtual size_t PhysicalSize() const = 0;

X
Xu Peng 已提交
28
    virtual Status Serialize() = 0;
X
Xu Peng 已提交
29

X
Xu Peng 已提交
30 31
    virtual Status Load() = 0;

32 33
    virtual Status Merge(const std::string& location) = 0;

34 35 36 37 38 39
    virtual Status Search(long n,
                          const float *data,
                          long k,
                          float *distances,
                          long *labels) const = 0;

X
Xu Peng 已提交
40 41
    virtual std::shared_ptr<ExecutionEngine> BuildIndex(const std::string&) = 0;

X
Xu Peng 已提交
42 43
    virtual Status Cache() = 0;

X
Xu Peng 已提交
44
    virtual ~ExecutionEngine() {}
X
Xu Peng 已提交
45 46
};

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
template <typename Derived>
class ExecutionEngineBase {
public:

    Status AddWithIds(const std::vector<float>& vectors,
                              const std::vector<long>& vector_ids);

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

    size_t Count() const;

    size_t Size() const;

    size_t PhysicalSize() const;

    Status Serialize();

    Status Load();

    Status Merge(const std::string& location);

    Status Search(long n,
                  const float *data,
                  long k,
                  float *distances,
                  long *labels) const;

    std::shared_ptr<Derived> BuildIndex(const std::string&);

    Status Cache();
};

X
Xu Peng 已提交
79 80 81 82

} // namespace engine
} // namespace vecwise
} // namespace zilliz