SqliteMetaImpl.h 4.0 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 "Meta.h"
S
starlord 已提交
21
#include "db/Options.h"
X
Xu Peng 已提交
22

23
#include <mutex>
S
starlord 已提交
24
#include <string>
S
starlord 已提交
25
#include <vector>
J
jinhai 已提交
26

J
jinhai 已提交
27
namespace milvus {
X
Xu Peng 已提交
28
namespace engine {
29
namespace meta {
X
Xu Peng 已提交
30

S
starlord 已提交
31
auto
S
starlord 已提交
32
StoragePrototype(const std::string& path);
X
Xu Peng 已提交
33

S
starlord 已提交
34
class SqliteMetaImpl : public Meta {
J
jinhai 已提交
35
 public:
S
starlord 已提交
36
    explicit SqliteMetaImpl(const DBMetaOptions& options);
37
    ~SqliteMetaImpl();
J
jinhai 已提交
38

S
starlord 已提交
39 40
    Status
    CreateTable(TableSchema& table_schema) override;
J
jinhai 已提交
41

S
starlord 已提交
42 43
    Status
    DescribeTable(TableSchema& table_schema) override;
J
jinhai 已提交
44

S
starlord 已提交
45 46
    Status
    HasTable(const std::string& table_id, bool& has_or_not) override;
J
jinhai 已提交
47

S
starlord 已提交
48 49
    Status
    AllTables(std::vector<TableSchema>& table_schema_array) override;
J
jinhai 已提交
50

S
starlord 已提交
51
    Status
G
groot 已提交
52
    DropTable(const std::string& table_id) override;
X
Xu Peng 已提交
53

S
starlord 已提交
54 55
    Status
    DeleteTableFiles(const std::string& table_id) override;
56

S
starlord 已提交
57 58
    Status
    CreateTableFile(TableFileSchema& file_schema) override;
G
groot 已提交
59

S
starlord 已提交
60
    Status
G
groot 已提交
61
    DropDataByDate(const std::string& table_id, const DatesT& dates) override;
X
Xu Peng 已提交
62

S
starlord 已提交
63 64
    Status
    GetTableFiles(const std::string& table_id, const std::vector<size_t>& ids, TableFilesSchema& table_files) override;
S
starlord 已提交
65

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

S
starlord 已提交
69 70
    Status
    UpdateTableFlag(const std::string& table_id, int64_t flag) override;
71

G
groot 已提交
72 73 74 75 76 77 78 79 80
    Status
    UpdateTableFile(TableFileSchema& file_schema) override;

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

    Status
    UpdateTableFiles(TableFilesSchema& files) override;

S
starlord 已提交
81 82
    Status
    DescribeTableIndex(const std::string& table_id, TableIndex& index) override;
83

S
starlord 已提交
84 85
    Status
    DropTableIndex(const std::string& table_id) override;
86

S
starlord 已提交
87
    Status
G
groot 已提交
88
    CreatePartition(const std::string& table_id, const std::string& partition_name, const std::string& tag) override;
P
peng.xu 已提交
89

S
starlord 已提交
90
    Status
G
groot 已提交
91
    DropPartition(const std::string& partition_name) override;
92

S
starlord 已提交
93
    Status
G
groot 已提交
94 95 96 97
    ShowPartitions(const std::string& table_id, std::vector<meta::TableSchema>& partiton_schema_array) override;

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

S
starlord 已提交
99
    Status
100
    FilesToSearch(const std::string& table_id, const std::vector<size_t>& ids, const DatesT& dates,
S
starlord 已提交
101
                  DatePartionedTableFilesSchema& files) override;
X
xj.lin 已提交
102

S
starlord 已提交
103 104
    Status
    FilesToMerge(const std::string& table_id, DatePartionedTableFilesSchema& files) override;
X
Xu Peng 已提交
105

S
starlord 已提交
106 107
    Status
    FilesToIndex(TableFilesSchema&) override;
X
Xu Peng 已提交
108

S
starlord 已提交
109
    Status
G
groot 已提交
110 111
    FilesByType(const std::string& table_id, const std::vector<int>& file_types,
                std::vector<std::string>& file_ids) override;
X
Xu Peng 已提交
112

S
starlord 已提交
113 114
    Status
    Size(uint64_t& result) override;
X
Xu Peng 已提交
115

G
groot 已提交
116 117 118
    Status
    Archive() override;

S
starlord 已提交
119 120
    Status
    CleanUp() override;
X
Xu Peng 已提交
121

S
starlord 已提交
122 123
    Status
    CleanUpFilesWithTTL(uint16_t seconds) override;
X
Xu Peng 已提交
124

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

S
starlord 已提交
128 129
    Status
    Count(const std::string& table_id, uint64_t& result) override;
X
Xu Peng 已提交
130

J
jinhai 已提交
131
 private:
S
starlord 已提交
132 133 134 135 136 137 138 139 140 141 142
    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 已提交
143

S
starlord 已提交
144
 private:
X
Xu Peng 已提交
145
    const DBMetaOptions options_;
146
    std::mutex meta_mutex_;
G
groot 已提交
147
    std::mutex genid_mutex_;
S
starlord 已提交
148
};  // DBMetaImpl
X
Xu Peng 已提交
149

S
starlord 已提交
150 151 152
}  // namespace meta
}  // namespace engine
}  // namespace milvus