Meta.h 4.4 KB
Newer Older
1
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
J
jinhai 已提交
2
//
3 4
// Licensed 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
J
jinhai 已提交
5
//
6 7 8 9 10
// 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.
J
jinhai 已提交
11

X
Xu Peng 已提交
12
#pragma once
X
Xu Peng 已提交
13

X
Xu Peng 已提交
14 15
#include <cstddef>
#include <memory>
S
starlord 已提交
16
#include <string>
S
starlord 已提交
17
#include <vector>
X
Xu Peng 已提交
18

19 20 21 22 23
#include "MetaTypes.h"
#include "db/Options.h"
#include "db/Types.h"
#include "utils/Status.h"

J
jinhai 已提交
24
namespace milvus {
X
Xu Peng 已提交
25
namespace engine {
26 27
namespace meta {

28
static const char* META_ENVIRONMENT = "Environment";
S
starlord 已提交
29 30
static const char* META_TABLES = "Tables";
static const char* META_TABLEFILES = "TableFiles";
31

X
Xu Peng 已提交
32
class Meta {
33
    /*
G
groot 已提交
34 35 36 37 38 39
 public:
    class CleanUpFilter {
     public:
        virtual bool
        IsIgnored(const TableFileSchema& schema) = 0;
    };
40
*/
G
groot 已提交
41

42
 public:
43
    virtual ~Meta() = default;
44

S
starlord 已提交
45 46
    virtual Status
    CreateTable(TableSchema& table_schema) = 0;
P
peng.xu 已提交
47

S
starlord 已提交
48 49
    virtual Status
    DescribeTable(TableSchema& table_schema) = 0;
50

S
starlord 已提交
51 52
    virtual Status
    HasTable(const std::string& table_id, bool& has_or_not) = 0;
S
starlord 已提交
53

S
starlord 已提交
54 55
    virtual Status
    AllTables(std::vector<TableSchema>& table_schema_array) = 0;
56

S
starlord 已提交
57 58
    virtual Status
    UpdateTableFlag(const std::string& table_id, int64_t flag) = 0;
X
xj.lin 已提交
59

60 61 62 63 64 65 66 67 68
    virtual Status
    UpdateTableFlushLSN(const std::string& table_id, uint64_t flush_lsn) = 0;

    virtual Status
    GetTableFlushLSN(const std::string& table_id, uint64_t& flush_lsn) = 0;

    virtual Status
    GetTableFilesByFlushLSN(uint64_t flush_lsn, TableFilesSchema& table_files) = 0;

S
starlord 已提交
69
    virtual Status
G
groot 已提交
70
    DropTable(const std::string& table_id) = 0;
X
Xu Peng 已提交
71

S
starlord 已提交
72 73
    virtual Status
    DeleteTableFiles(const std::string& table_id) = 0;
X
Xu Peng 已提交
74

S
starlord 已提交
75 76
    virtual Status
    CreateTableFile(TableFileSchema& file_schema) = 0;
X
Xu Peng 已提交
77

S
starlord 已提交
78
    virtual Status
79
    GetTableFiles(const std::string& table_id, const std::vector<size_t>& ids, TableFilesSchema& table_files) = 0;
X
Xu Peng 已提交
80

S
starlord 已提交
81
    virtual Status
82
    GetTableFilesBySegmentId(const std::string& segment_id, TableFilesSchema& table_files) = 0;
P
peng.xu 已提交
83

G
groot 已提交
84 85 86 87 88 89
    virtual Status
    UpdateTableFile(TableFileSchema& file_schema) = 0;

    virtual Status
    UpdateTableFiles(TableFilesSchema& files) = 0;

90 91 92
    virtual Status
    UpdateTableFilesRowCount(TableFilesSchema& files) = 0;

G
groot 已提交
93 94 95
    virtual Status
    UpdateTableIndex(const std::string& table_id, const TableIndex& index) = 0;

S
starlord 已提交
96 97
    virtual Status
    UpdateTableFilesToIndex(const std::string& table_id) = 0;
X
xj.lin 已提交
98

S
starlord 已提交
99
    virtual Status
G
groot 已提交
100
    DescribeTableIndex(const std::string& table_id, TableIndex& index) = 0;
X
Xu Peng 已提交
101

S
starlord 已提交
102
    virtual Status
G
groot 已提交
103
    DropTableIndex(const std::string& table_id) = 0;
X
Xu Peng 已提交
104

S
starlord 已提交
105
    virtual Status
106 107
    CreatePartition(const std::string& table_name, const std::string& partition_name, const std::string& tag,
                    uint64_t lsn) = 0;
108

S
starlord 已提交
109
    virtual Status
G
groot 已提交
110
    DropPartition(const std::string& partition_name) = 0;
111

S
starlord 已提交
112
    virtual Status
G
groot 已提交
113
    ShowPartitions(const std::string& table_name, std::vector<meta::TableSchema>& partition_schema_array) = 0;
114

S
starlord 已提交
115
    virtual Status
G
groot 已提交
116 117 118
    GetPartitionName(const std::string& table_name, const std::string& tag, std::string& partition_name) = 0;

    virtual Status
119
    FilesToSearch(const std::string& table_id, TableFilesSchema& files) = 0;
G
groot 已提交
120 121

    virtual Status
122
    FilesToMerge(const std::string& table_id, TableFilesSchema& files) = 0;
123

S
starlord 已提交
124 125
    virtual Status
    FilesToIndex(TableFilesSchema&) = 0;
126

S
starlord 已提交
127
    virtual Status
128 129 130 131
    FilesByType(const std::string& table_id, const std::vector<int>& file_types, TableFilesSchema& files) = 0;

    virtual Status
    FilesByID(const std::vector<size_t>& ids, TableFilesSchema& files) = 0;
132

S
starlord 已提交
133
    virtual Status
G
groot 已提交
134
    Size(uint64_t& result) = 0;
135

S
starlord 已提交
136
    virtual Status
G
groot 已提交
137
    Archive() = 0;
138

S
starlord 已提交
139
    virtual Status
140
    CleanUpShadowFiles() = 0;
141

142
    virtual Status
143
    CleanUpFilesWithTTL(uint64_t seconds /*, CleanUpFilter* filter = nullptr*/) = 0;
144

S
starlord 已提交
145 146
    virtual Status
    DropAll() = 0;
147

S
starlord 已提交
148 149
    virtual Status
    Count(const std::string& table_id, uint64_t& result) = 0;
150 151 152 153 154 155

    virtual Status
    SetGlobalLastLSN(uint64_t lsn) = 0;

    virtual Status
    GetGlobalLastLSN(uint64_t& lsn) = 0;
S
starlord 已提交
156
};  // MetaData
X
Xu Peng 已提交
157

S
starlord 已提交
158 159
using MetaPtr = std::shared_ptr<Meta>;

S
starlord 已提交
160 161 162
}  // namespace meta
}  // namespace engine
}  // namespace milvus