Meta.h 3.8 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 "MetaTypes.h"
S
starlord 已提交
21
#include "db/Options.h"
22
#include "db/Types.h"
S
starlord 已提交
23
#include "utils/Status.h"
X
Xu Peng 已提交
24

X
Xu Peng 已提交
25 26
#include <cstddef>
#include <memory>
S
starlord 已提交
27
#include <string>
S
starlord 已提交
28
#include <vector>
X
Xu Peng 已提交
29

J
jinhai 已提交
30
namespace milvus {
X
Xu Peng 已提交
31
namespace engine {
32 33
namespace meta {

S
starlord 已提交
34 35
static const char* META_TABLES = "Tables";
static const char* META_TABLEFILES = "TableFiles";
36

X
Xu Peng 已提交
37
class Meta {
38
 public:
39
    virtual ~Meta() = default;
40

S
starlord 已提交
41 42
    virtual Status
    CreateTable(TableSchema& table_schema) = 0;
P
peng.xu 已提交
43

S
starlord 已提交
44 45
    virtual Status
    DescribeTable(TableSchema& table_schema) = 0;
46

S
starlord 已提交
47 48
    virtual Status
    HasTable(const std::string& table_id, bool& has_or_not) = 0;
S
starlord 已提交
49

S
starlord 已提交
50 51
    virtual Status
    AllTables(std::vector<TableSchema>& table_schema_array) = 0;
52

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

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

S
starlord 已提交
59 60
    virtual Status
    DeleteTableFiles(const std::string& table_id) = 0;
X
Xu Peng 已提交
61

S
starlord 已提交
62 63
    virtual Status
    CreateTableFile(TableFileSchema& file_schema) = 0;
X
Xu Peng 已提交
64

S
starlord 已提交
65
    virtual Status
G
groot 已提交
66
    DropDataByDate(const std::string& table_id, const DatesT& dates) = 0;
X
Xu Peng 已提交
67

S
starlord 已提交
68 69
    virtual Status
    GetTableFiles(const std::string& table_id, const std::vector<size_t>& ids, TableFilesSchema& table_files) = 0;
P
peng.xu 已提交
70

G
groot 已提交
71 72 73 74 75 76 77 78 79
    virtual Status
    UpdateTableFile(TableFileSchema& file_schema) = 0;

    virtual Status
    UpdateTableFiles(TableFilesSchema& files) = 0;

    virtual Status
    UpdateTableIndex(const std::string& table_id, const TableIndex& index) = 0;

S
starlord 已提交
80 81
    virtual Status
    UpdateTableFilesToIndex(const std::string& table_id) = 0;
X
xj.lin 已提交
82

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

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

S
starlord 已提交
89
    virtual Status
G
groot 已提交
90
    CreatePartition(const std::string& table_name, const std::string& partition_name, const std::string& tag) = 0;
91

S
starlord 已提交
92
    virtual Status
G
groot 已提交
93
    DropPartition(const std::string& partition_name) = 0;
94

S
starlord 已提交
95
    virtual Status
G
groot 已提交
96
    ShowPartitions(const std::string& table_name, std::vector<meta::TableSchema>& partiton_schema_array) = 0;
97

S
starlord 已提交
98
    virtual Status
G
groot 已提交
99 100 101 102 103 104 105 106
    GetPartitionName(const std::string& table_name, const std::string& tag, std::string& partition_name) = 0;

    virtual Status
    FilesToSearch(const std::string& table_id, const std::vector<size_t>& ids, const DatesT& dates,
                  DatePartionedTableFilesSchema& files) = 0;

    virtual Status
    FilesToMerge(const std::string& table_id, DatePartionedTableFilesSchema& files) = 0;
107

S
starlord 已提交
108 109
    virtual Status
    FilesToIndex(TableFilesSchema&) = 0;
110

S
starlord 已提交
111
    virtual Status
G
groot 已提交
112
    FilesByType(const std::string& table_id, const std::vector<int>& file_types, TableFilesSchema& table_files) = 0;
113

S
starlord 已提交
114
    virtual Status
G
groot 已提交
115
    Size(uint64_t& result) = 0;
116

S
starlord 已提交
117
    virtual Status
G
groot 已提交
118
    Archive() = 0;
119

S
starlord 已提交
120 121
    virtual Status
    CleanUp() = 0;
122

123
    virtual Status CleanUpFilesWithTTL(uint16_t) = 0;
124

S
starlord 已提交
125 126
    virtual Status
    DropAll() = 0;
127

S
starlord 已提交
128 129 130
    virtual Status
    Count(const std::string& table_id, uint64_t& result) = 0;
};  // MetaData
X
Xu Peng 已提交
131

S
starlord 已提交
132 133
using MetaPtr = std::shared_ptr<Meta>;

S
starlord 已提交
134 135 136
}  // namespace meta
}  // namespace engine
}  // namespace milvus