MySQLMetaImpl.h 3.1 KB
Newer Older
Z
zhiru 已提交
1 2 3 4 5 6 7 8 9
/*******************************************************************************
 * Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 * Proprietary and confidential.
 ******************************************************************************/
#pragma once

#include "Meta.h"
#include "Options.h"
Z
zhiru 已提交
10
#include "MySQLConnectionPool.h"
Z
zhiru 已提交
11

Z
zhiru 已提交
12 13 14
#include "mysql++/mysql++.h"
#include <mutex>

J
jinhai 已提交
15

Z
zhiru 已提交
16 17 18 19 20 21
namespace zilliz {
namespace milvus {
namespace engine {
namespace meta {

//    auto StoragePrototype(const std::string& path);
J
jinhai 已提交
22
using namespace mysqlpp;
Z
zhiru 已提交
23

J
jinhai 已提交
24 25 26
class MySQLMetaImpl : public Meta {
 public:
    MySQLMetaImpl(const DBMetaOptions &options_, const int &mode);
Z
zhiru 已提交
27

J
jinhai 已提交
28 29 30 31
    Status CreateTable(TableSchema &table_schema) override;
    Status DescribeTable(TableSchema &group_info_) override;
    Status HasTable(const std::string &table_id, bool &has_or_not) override;
    Status AllTables(std::vector<TableSchema> &table_schema_array) override;
Z
zhiru 已提交
32

J
jinhai 已提交
33 34
    Status DeleteTable(const std::string &table_id) override;
    Status DeleteTableFiles(const std::string &table_id) override;
Z
update  
zhiru 已提交
35

J
jinhai 已提交
36 37 38
    Status CreateTableFile(TableFileSchema &file_schema) override;
    Status DropPartitionsByDates(const std::string &table_id,
                                 const DatesT &dates) override;
Z
zhiru 已提交
39

J
jinhai 已提交
40 41 42
    Status GetTableFiles(const std::string &table_id,
                         const std::vector<size_t> &ids,
                         TableFilesSchema &table_files) override;
Z
zhiru 已提交
43

J
jinhai 已提交
44
    Status HasNonIndexFiles(const std::string &table_id, bool &has) override;
P
peng.xu 已提交
45

J
jinhai 已提交
46
    Status UpdateTableFile(TableFileSchema &file_schema) override;
Z
zhiru 已提交
47

J
jinhai 已提交
48
    Status UpdateTableFilesToIndex(const std::string &table_id) override;
P
peng.xu 已提交
49

J
jinhai 已提交
50
    Status UpdateTableFiles(TableFilesSchema &files) override;
Z
zhiru 已提交
51

J
jinhai 已提交
52 53 54
    Status FilesToSearch(const std::string &table_id,
                         const DatesT &partition,
                         DatePartionedTableFilesSchema &files) override;
X
xj.lin 已提交
55 56 57 58 59

    Status FilesToSearch(const std::string &table_id,
                         const std::vector<size_t> &ids,
                         const DatesT &partition,
                         DatePartionedTableFilesSchema &files) override;
Z
zhiru 已提交
60

J
jinhai 已提交
61 62
    Status FilesToMerge(const std::string &table_id,
                        DatePartionedTableFilesSchema &files) override;
Z
zhiru 已提交
63

J
jinhai 已提交
64
    Status FilesToIndex(TableFilesSchema &) override;
Z
zhiru 已提交
65

J
jinhai 已提交
66
    Status Archive() override;
Z
zhiru 已提交
67

J
jinhai 已提交
68
    Status Size(uint64_t &result) override;
Z
zhiru 已提交
69

J
jinhai 已提交
70
    Status CleanUp() override;
Z
zhiru 已提交
71

J
jinhai 已提交
72
    Status CleanUpFilesWithTTL(uint16_t seconds) override;
Z
zhiru 已提交
73

J
jinhai 已提交
74
    Status DropAll() override;
Z
zhiru 已提交
75

J
jinhai 已提交
76
    Status Count(const std::string &table_id, uint64_t &result) override;
Z
zhiru 已提交
77

J
jinhai 已提交
78
    virtual ~MySQLMetaImpl();
Z
zhiru 已提交
79

J
jinhai 已提交
80 81 82 83 84
 private:
    Status NextFileId(std::string &file_id);
    Status NextTableId(std::string &table_id);
    Status DiscardFiles(long long to_discard_size);
    Status Initialize();
Z
zhiru 已提交
85

J
jinhai 已提交
86 87
    const DBMetaOptions options_;
    const int mode_;
Z
zhiru 已提交
88

J
jinhai 已提交
89 90
    std::shared_ptr<MySQLConnectionPool> mysql_connection_pool_;
    bool safe_grab = false;
Z
zhiru 已提交
91

Z
zhiru 已提交
92
//        std::mutex connectionMutex_;
J
jinhai 已提交
93
}; // DBMetaImpl
Z
zhiru 已提交
94 95 96 97 98

} // namespace meta
} // namespace engine
} // namespace milvus
} // namespace zilliz