SqliteMetaImpl.h 4.3 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

14
#include <mutex>
S
starlord 已提交
15
#include <string>
S
starlord 已提交
16
#include <vector>
J
jinhai 已提交
17

18 19 20
#include "Meta.h"
#include "db/Options.h"

J
jinhai 已提交
21
namespace milvus {
X
Xu Peng 已提交
22
namespace engine {
23
namespace meta {
X
Xu Peng 已提交
24

S
starlord 已提交
25
auto
S
starlord 已提交
26
StoragePrototype(const std::string& path);
X
Xu Peng 已提交
27

S
starlord 已提交
28
class SqliteMetaImpl : public Meta {
J
jinhai 已提交
29
 public:
S
starlord 已提交
30
    explicit SqliteMetaImpl(const DBMetaOptions& options);
31
    ~SqliteMetaImpl();
J
jinhai 已提交
32

S
starlord 已提交
33 34
    Status
    CreateTable(TableSchema& table_schema) override;
J
jinhai 已提交
35

S
starlord 已提交
36 37
    Status
    DescribeTable(TableSchema& table_schema) override;
J
jinhai 已提交
38

S
starlord 已提交
39 40
    Status
    HasTable(const std::string& table_id, bool& has_or_not) override;
J
jinhai 已提交
41

S
starlord 已提交
42 43
    Status
    AllTables(std::vector<TableSchema>& table_schema_array) override;
J
jinhai 已提交
44

S
starlord 已提交
45
    Status
G
groot 已提交
46
    DropTable(const std::string& table_id) override;
X
Xu Peng 已提交
47

S
starlord 已提交
48 49
    Status
    DeleteTableFiles(const std::string& table_id) override;
50

S
starlord 已提交
51 52
    Status
    CreateTableFile(TableFileSchema& file_schema) override;
G
groot 已提交
53

S
starlord 已提交
54
    Status
55
    GetTableFiles(const std::string& table_id, const std::vector<size_t>& ids, TableFilesSchema& table_files) override;
X
Xu Peng 已提交
56

S
starlord 已提交
57
    Status
58
    GetTableFilesBySegmentId(const std::string& segment_id, TableFilesSchema& table_files) override;
S
starlord 已提交
59

S
starlord 已提交
60 61
    Status
    UpdateTableIndex(const std::string& table_id, const TableIndex& index) override;
P
peng.xu 已提交
62

S
starlord 已提交
63 64
    Status
    UpdateTableFlag(const std::string& table_id, int64_t flag) override;
65

66 67 68 69 70 71 72 73 74
    Status
    UpdateTableFlushLSN(const std::string& table_id, uint64_t flush_lsn) override;

    Status
    GetTableFlushLSN(const std::string& table_id, uint64_t& flush_lsn) override;

    Status
    GetTableFilesByFlushLSN(uint64_t flush_lsn, TableFilesSchema& table_files) override;

G
groot 已提交
75 76 77 78 79 80 81 82 83
    Status
    UpdateTableFile(TableFileSchema& file_schema) override;

    Status
    UpdateTableFilesToIndex(const std::string& table_id) override;

    Status
    UpdateTableFiles(TableFilesSchema& files) override;

84 85 86
    Status
    UpdateTableFilesRowCount(TableFilesSchema& files) override;

S
starlord 已提交
87 88
    Status
    DescribeTableIndex(const std::string& table_id, TableIndex& index) override;
89

S
starlord 已提交
90 91
    Status
    DropTableIndex(const std::string& table_id) override;
92

S
starlord 已提交
93
    Status
94 95
    CreatePartition(const std::string& table_id, const std::string& partition_name, const std::string& tag,
                    uint64_t lsn) override;
P
peng.xu 已提交
96

S
starlord 已提交
97
    Status
G
groot 已提交
98
    DropPartition(const std::string& partition_name) override;
99

S
starlord 已提交
100
    Status
G
groot 已提交
101
    ShowPartitions(const std::string& table_id, std::vector<meta::TableSchema>& partition_schema_array) override;
G
groot 已提交
102 103 104

    Status
    GetPartitionName(const std::string& table_id, const std::string& tag, std::string& partition_name) override;
105

S
starlord 已提交
106
    Status
107
    FilesToSearch(const std::string& table_id, const std::vector<size_t>& ids, TableFilesSchema& files) override;
X
xj.lin 已提交
108

S
starlord 已提交
109
    Status
110
    FilesToMerge(const std::string& table_id, TableFilesSchema& files) override;
X
Xu Peng 已提交
111

S
starlord 已提交
112 113
    Status
    FilesToIndex(TableFilesSchema&) override;
X
Xu Peng 已提交
114

S
starlord 已提交
115
    Status
G
groot 已提交
116
    FilesByType(const std::string& table_id, const std::vector<int>& file_types,
G
groot 已提交
117
                TableFilesSchema& table_files) override;
X
Xu Peng 已提交
118

S
starlord 已提交
119 120
    Status
    Size(uint64_t& result) override;
X
Xu Peng 已提交
121

G
groot 已提交
122 123 124
    Status
    Archive() override;

S
starlord 已提交
125
    Status
126
    CleanUpShadowFiles() override;
X
Xu Peng 已提交
127

128
    Status
129
    CleanUpFilesWithTTL(uint64_t seconds /*, CleanUpFilter* filter = nullptr*/) override;
X
Xu Peng 已提交
130

S
starlord 已提交
131 132
    Status
    DropAll() override;
X
Xu Peng 已提交
133

S
starlord 已提交
134 135
    Status
    Count(const std::string& table_id, uint64_t& result) override;
X
Xu Peng 已提交
136

137 138 139 140 141 142
    Status
    SetGlobalLastLSN(uint64_t lsn) override;

    Status
    GetGlobalLastLSN(uint64_t& lsn) override;

J
jinhai 已提交
143
 private:
S
starlord 已提交
144 145 146 147 148 149 150 151 152 153 154
    Status
    NextFileId(std::string& file_id);
    Status
    NextTableId(std::string& table_id);
    Status
    DiscardFiles(int64_t to_discard_size);

    void
    ValidateMetaSchema();
    Status
    Initialize();
X
Xu Peng 已提交
155

S
starlord 已提交
156
 private:
X
Xu Peng 已提交
157
    const DBMetaOptions options_;
158
    std::mutex meta_mutex_;
G
groot 已提交
159
    std::mutex genid_mutex_;
S
starlord 已提交
160
};  // DBMetaImpl
X
Xu Peng 已提交
161

S
starlord 已提交
162 163 164
}  // namespace meta
}  // namespace engine
}  // namespace milvus