Meta.h 4.5 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
 public:
    class CleanUpFilter {
     public:
        virtual bool
J
Jin Hai 已提交
38
        IsIgnored(const SegmentSchema& schema) = 0;
G
groot 已提交
39
    };
40
*/
G
groot 已提交
41

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

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

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

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

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

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

60
    virtual Status
J
Jin Hai 已提交
61
    UpdateTableFlushLSN(const std::string& collection_id, uint64_t flush_lsn) = 0;
62 63

    virtual Status
64
    GetCollectionFlushLSN(const std::string& collection_id, uint64_t& flush_lsn) = 0;
65

S
starlord 已提交
66
    virtual Status
67
    DropCollection(const std::string& collection_id) = 0;
X
Xu Peng 已提交
68

S
starlord 已提交
69
    virtual Status
J
Jin Hai 已提交
70
    DeleteTableFiles(const std::string& collection_id) = 0;
X
Xu Peng 已提交
71

S
starlord 已提交
72
    virtual Status
73
    CreateCollectionFile(SegmentSchema& file_schema) = 0;
X
Xu Peng 已提交
74

S
starlord 已提交
75
    virtual Status
J
Jin Hai 已提交
76
    GetTableFiles(const std::string& collection_id, const std::vector<size_t>& ids, SegmentsSchema& table_files) = 0;
X
Xu Peng 已提交
77

S
starlord 已提交
78
    virtual Status
79
    GetCollectionFilesBySegmentId(const std::string& segment_id, SegmentsSchema& table_files) = 0;
P
peng.xu 已提交
80

G
groot 已提交
81
    virtual Status
82
    UpdateCollectionFile(SegmentSchema& file_schema) = 0;
G
groot 已提交
83 84

    virtual Status
85
    UpdateCollectionFiles(SegmentsSchema& files) = 0;
G
groot 已提交
86

87
    virtual Status
88
    UpdateCollectionFilesRowCount(SegmentsSchema& files) = 0;
89

G
groot 已提交
90
    virtual Status
91
    UpdateCollectionIndex(const std::string& collection_id, const CollectionIndex& index) = 0;
G
groot 已提交
92

S
starlord 已提交
93
    virtual Status
94
    UpdateCollectionFilesToIndex(const std::string& collection_id) = 0;
X
xj.lin 已提交
95

S
starlord 已提交
96
    virtual Status
97
    DescribeCollectionIndex(const std::string& collection_id, CollectionIndex& index) = 0;
X
Xu Peng 已提交
98

S
starlord 已提交
99
    virtual Status
100
    DropCollectionIndex(const std::string& collection_id) = 0;
X
Xu Peng 已提交
101

S
starlord 已提交
102
    virtual Status
J
Jin Hai 已提交
103
    CreatePartition(const std::string& collection_name, const std::string& partition_name, const std::string& tag,
104
                    uint64_t lsn) = 0;
105

S
starlord 已提交
106
    virtual Status
G
groot 已提交
107
    DropPartition(const std::string& partition_name) = 0;
108

S
starlord 已提交
109
    virtual Status
J
Jin Hai 已提交
110
    ShowPartitions(const std::string& collection_name, std::vector<meta::CollectionSchema>& partition_schema_array) = 0;
111

S
starlord 已提交
112
    virtual Status
J
Jin Hai 已提交
113
    GetPartitionName(const std::string& collection_name, const std::string& tag, std::string& partition_name) = 0;
G
groot 已提交
114 115

    virtual Status
J
Jin Hai 已提交
116
    FilesToSearch(const std::string& collection_id, SegmentsSchema& files) = 0;
G
groot 已提交
117 118

    virtual Status
J
Jin Hai 已提交
119
    FilesToMerge(const std::string& collection_id, SegmentsSchema& files) = 0;
120

S
starlord 已提交
121
    virtual Status
J
Jin Hai 已提交
122
    FilesToIndex(SegmentsSchema&) = 0;
123

S
starlord 已提交
124
    virtual Status
J
Jin Hai 已提交
125
    FilesByType(const std::string& collection_id, const std::vector<int>& file_types, SegmentsSchema& files) = 0;
126 127

    virtual Status
J
Jin Hai 已提交
128
    FilesByID(const std::vector<size_t>& ids, SegmentsSchema& files) = 0;
129

S
starlord 已提交
130
    virtual Status
G
groot 已提交
131
    Size(uint64_t& result) = 0;
132

S
starlord 已提交
133
    virtual Status
G
groot 已提交
134
    Archive() = 0;
135

S
starlord 已提交
136
    virtual Status
137
    CleanUpShadowFiles() = 0;
138

139
    virtual Status
140
    CleanUpFilesWithTTL(uint64_t seconds /*, CleanUpFilter* filter = nullptr*/) = 0;
141

S
starlord 已提交
142 143
    virtual Status
    DropAll() = 0;
144

S
starlord 已提交
145
    virtual Status
J
Jin Hai 已提交
146
    Count(const std::string& collection_id, uint64_t& result) = 0;
147 148 149 150 151 152

    virtual Status
    SetGlobalLastLSN(uint64_t lsn) = 0;

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

S
starlord 已提交
155 156
using MetaPtr = std::shared_ptr<Meta>;

S
starlord 已提交
157 158 159
}  // namespace meta
}  // namespace engine
}  // namespace milvus