DB.h 2.9 KB
Newer Older
J
jinhai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

X
Xu Peng 已提交
18
#pragma once
X
Xu Peng 已提交
19

X
Xu Peng 已提交
20
#include "Options.h"
G
groot 已提交
21
#include "meta/Meta.h"
X
Xu Peng 已提交
22
#include "Status.h"
X
Xu Peng 已提交
23
#include "Types.h"
X
Xu Peng 已提交
24

X
Xu Peng 已提交
25
#include <string>
G
groot 已提交
26
#include <memory>
X
Xu Peng 已提交
27

X
Xu Peng 已提交
28
namespace zilliz {
J
jinhai 已提交
29
namespace milvus {
X
Xu Peng 已提交
30
namespace engine {
X
Xu Peng 已提交
31 32 33 34 35

class Env;

class DB {
public:
G
groot 已提交
36 37 38 39 40
    DB() = default;
    DB(const DB&) = delete;
    DB& operator=(const DB&) = delete;

    virtual ~DB() = default;
X
Xu Peng 已提交
41

G
groot 已提交
42 43 44
    virtual Status Start() = 0;
    virtual Status Stop() = 0;

X
Xu Peng 已提交
45
    virtual Status CreateTable(meta::TableSchema& table_schema_) = 0;
G
groot 已提交
46
    virtual Status DeleteTable(const std::string& table_id, const meta::DatesT& dates) = 0;
X
Xu Peng 已提交
47
    virtual Status DescribeTable(meta::TableSchema& table_schema_) = 0;
G
groot 已提交
48 49 50
    virtual Status HasTable(const std::string& table_id, bool& has_or_not_) = 0;
    virtual Status AllTables(std::vector<meta::TableSchema>& table_schema_array) = 0;
    virtual Status GetTableRowCount(const std::string& table_id, uint64_t& row_count) = 0;
Y
Yu Kun 已提交
51
    virtual Status PreloadTable(const std::string& table_id) = 0;
G
groot 已提交
52
    virtual Status UpdateTableFlag(const std::string &table_id, int64_t flag) = 0;
X
Xu Peng 已提交
53

X
Xu Peng 已提交
54
    virtual Status InsertVectors(const std::string& table_id_,
G
groot 已提交
55
            uint64_t n, const float* vectors, IDNumbers& vector_ids_) = 0;
56

Y
Yu Kun 已提交
57
    virtual Status Query(const std::string& table_id, uint64_t k, uint64_t nq, uint64_t nprobe,
X
Xu Peng 已提交
58 59
            const float* vectors, QueryResults& results) = 0;

Y
Yu Kun 已提交
60
    virtual Status Query(const std::string& table_id, uint64_t k, uint64_t nq, uint64_t nprobe,
X
Xu Peng 已提交
61 62
            const float* vectors, const meta::DatesT& dates, QueryResults& results) = 0;

63
    virtual Status Query(const std::string& table_id, const std::vector<std::string>& file_ids,
Y
Yu Kun 已提交
64
            uint64_t k, uint64_t nq, uint64_t nprobe, const float* vectors,
65 66
            const meta::DatesT& dates, QueryResults& results) = 0;

G
groot 已提交
67
    virtual Status Size(uint64_t& result) = 0;
X
Xu Peng 已提交
68

69 70 71
    virtual Status CreateIndex(const std::string& table_id, const TableIndex& index) = 0;
    virtual Status DescribeIndex(const std::string& table_id, TableIndex& index) = 0;
    virtual Status DropIndex(const std::string& table_id) = 0;
P
peng.xu 已提交
72

X
Xu Peng 已提交
73
    virtual Status DropAll() = 0;
X
Xu Peng 已提交
74

X
Xu Peng 已提交
75 76
}; // DB

G
groot 已提交
77 78
using DBPtr = std::shared_ptr<DB>;

X
Xu Peng 已提交
79
} // namespace engine
J
jinhai 已提交
80
} // namespace milvus
X
Xu Peng 已提交
81
} // namespace zilliz