Meta.h 5.1 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
#include "MetaTypes.h"
#include "db/Options.h"
#include "db/Types.h"
G
groot 已提交
22
#include "db/meta/FilesHolder.h"
23 24
#include "utils/Status.h"

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

C
Cai Yudong 已提交
29 30 31 32 33 34
extern const char* META_ENVIRONMENT;
extern const char* META_TABLES;
extern const char* META_TABLEFILES;
extern const char* META_COLLECTIONS;
extern const char* META_FIELDS;
extern const char* META_COLLECTIONFILES;
35

G
groot 已提交
36 37
class FilesHolder;

X
Xu Peng 已提交
38
class Meta {
39
    /*
G
groot 已提交
40 41 42 43
 public:
    class CleanUpFilter {
     public:
        virtual bool
J
Jin Hai 已提交
44
        IsIgnored(const SegmentSchema& schema) = 0;
G
groot 已提交
45
    };
46
*/
G
groot 已提交
47

48
 public:
49
    virtual ~Meta() = default;
50

S
starlord 已提交
51
    virtual Status
52
    CreateCollection(CollectionSchema& table_schema) = 0;
P
peng.xu 已提交
53

S
starlord 已提交
54
    virtual Status
55
    DescribeCollection(CollectionSchema& table_schema) = 0;
56

S
starlord 已提交
57
    virtual Status
G
groot 已提交
58
    HasCollection(const std::string& collection_id, bool& has_or_not, bool is_root = false) = 0;
S
starlord 已提交
59

S
starlord 已提交
60
    virtual Status
61
    AllCollections(std::vector<CollectionSchema>& table_schema_array) = 0;
62

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

66
    virtual Status
G
groot 已提交
67
    UpdateCollectionFlushLSN(const std::string& collection_id, uint64_t flush_lsn) = 0;
68 69

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

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

S
starlord 已提交
75
    virtual Status
G
groot 已提交
76
    DeleteCollectionFiles(const std::string& collection_id) = 0;
X
Xu Peng 已提交
77

S
starlord 已提交
78
    virtual Status
79
    CreateCollectionFile(SegmentSchema& file_schema) = 0;
X
Xu Peng 已提交
80

S
starlord 已提交
81
    virtual Status
G
groot 已提交
82
    GetCollectionFiles(const std::string& collection_id, const std::vector<size_t>& ids, FilesHolder& files_holder) = 0;
X
Xu Peng 已提交
83

S
starlord 已提交
84
    virtual Status
G
groot 已提交
85
    GetCollectionFilesBySegmentId(const std::string& segment_id, FilesHolder& files_holder) = 0;
P
peng.xu 已提交
86

G
groot 已提交
87
    virtual Status
88
    UpdateCollectionFile(SegmentSchema& file_schema) = 0;
G
groot 已提交
89 90

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

93
    virtual Status
94
    UpdateCollectionFilesRowCount(SegmentsSchema& files) = 0;
95

G
groot 已提交
96
    virtual Status
97
    UpdateCollectionIndex(const std::string& collection_id, const CollectionIndex& index) = 0;
G
groot 已提交
98

S
starlord 已提交
99
    virtual Status
100
    UpdateCollectionFilesToIndex(const std::string& collection_id) = 0;
X
xj.lin 已提交
101

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

S
starlord 已提交
105
    virtual Status
106
    DropCollectionIndex(const std::string& collection_id) = 0;
X
Xu Peng 已提交
107

S
starlord 已提交
108
    virtual Status
J
Jin Hai 已提交
109
    CreatePartition(const std::string& collection_name, const std::string& partition_name, const std::string& tag,
110
                    uint64_t lsn) = 0;
111

G
groot 已提交
112 113 114
    virtual Status
    HasPartition(const std::string& collection_id, const std::string& tag, bool& has_or_not) = 0;

S
starlord 已提交
115
    virtual Status
G
groot 已提交
116
    DropPartition(const std::string& partition_name) = 0;
117

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

S
starlord 已提交
121
    virtual Status
J
Jin Hai 已提交
122
    GetPartitionName(const std::string& collection_name, const std::string& tag, std::string& partition_name) = 0;
G
groot 已提交
123 124

    virtual Status
G
groot 已提交
125
    FilesToSearch(const std::string& collection_id, FilesHolder& files_holder) = 0;
G
groot 已提交
126 127

    virtual Status
G
groot 已提交
128
    FilesToMerge(const std::string& collection_id, FilesHolder& files_holder) = 0;
129

S
starlord 已提交
130
    virtual Status
G
groot 已提交
131
    FilesToIndex(FilesHolder& files_holder) = 0;
132

S
starlord 已提交
133
    virtual Status
G
groot 已提交
134
    FilesByType(const std::string& collection_id, const std::vector<int>& file_types, FilesHolder& files_holder) = 0;
135 136

    virtual Status
G
groot 已提交
137
    FilesByID(const std::vector<size_t>& ids, FilesHolder& files_holder) = 0;
138

S
starlord 已提交
139
    virtual Status
G
groot 已提交
140
    Size(uint64_t& result) = 0;
141

S
starlord 已提交
142
    virtual Status
G
groot 已提交
143
    Archive() = 0;
144

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

148
    virtual Status
149
    CleanUpFilesWithTTL(uint64_t seconds /*, CleanUpFilter* filter = nullptr*/) = 0;
150

S
starlord 已提交
151 152
    virtual Status
    DropAll() = 0;
153

S
starlord 已提交
154
    virtual Status
J
Jin Hai 已提交
155
    Count(const std::string& collection_id, uint64_t& result) = 0;
156 157 158 159 160 161

    virtual Status
    SetGlobalLastLSN(uint64_t lsn) = 0;

    virtual Status
    GetGlobalLastLSN(uint64_t& lsn) = 0;
162 163 164 165 166 167 168 169 170

    virtual Status
    CreateHybridCollection(CollectionSchema& collection_schema, hybrid::FieldsSchema& fields_schema) = 0;

    virtual Status
    DescribeHybridCollection(CollectionSchema& collection_schema, hybrid::FieldsSchema& fields_schema) = 0;

    virtual Status
    CreateHybridCollectionFile(SegmentSchema& file_schema) = 0;
S
starlord 已提交
171
};  // MetaData
X
Xu Peng 已提交
172

S
starlord 已提交
173 174
using MetaPtr = std::shared_ptr<Meta>;

S
starlord 已提交
175 176 177
}  // namespace meta
}  // namespace engine
}  // namespace milvus