MySQLMetaImpl.h 3.5 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>

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

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

    class MySQLMetaImpl : public Meta {
    public:
Z
update  
zhiru 已提交
25
        MySQLMetaImpl(const DBMetaOptions& options_, const int& mode);
Z
zhiru 已提交
26 27 28 29 30 31

        virtual Status CreateTable(TableSchema& table_schema) override;
        virtual Status DescribeTable(TableSchema& group_info_) override;
        virtual Status HasTable(const std::string& table_id, bool& has_or_not) override;
        virtual Status AllTables(std::vector<TableSchema>& table_schema_array) override;

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

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

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

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

Z
zhiru 已提交
45 46
        virtual Status UpdateTableFile(TableFileSchema& file_schema) override;

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

Z
zhiru 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
        virtual Status UpdateTableFiles(TableFilesSchema& files) override;

        virtual Status FilesToSearch(const std::string& table_id,
                                     const DatesT& partition,
                                     DatePartionedTableFilesSchema& files) override;

        virtual Status FilesToMerge(const std::string& table_id,
                                    DatePartionedTableFilesSchema& files) override;

        virtual Status FilesToIndex(TableFilesSchema&) override;

        virtual Status Archive() override;

        virtual Status Size(uint64_t& result) override;

        virtual Status CleanUp() override;

        virtual Status CleanUpFilesWithTTL(uint16_t seconds) override;

        virtual Status DropAll() override;

        virtual Status Count(const std::string& table_id, uint64_t& result) override;

        virtual ~MySQLMetaImpl();

    private:
        Status NextFileId(std::string& file_id);
        Status NextTableId(std::string& table_id);
Z
zhiru 已提交
77
        Status DiscardFiles(long long to_discard_size);
Z
zhiru 已提交
78 79 80
        std::string GetTablePath(const std::string& table_id);
        std::string GetTableDatePartitionPath(const std::string& table_id, DateT& date);
        void GetTableFilePath(TableFileSchema& group_file);
81
        Status Initialize();
Z
zhiru 已提交
82 83

        const DBMetaOptions options_;
Z
update  
zhiru 已提交
84
        const int mode_;
Z
zhiru 已提交
85

Z
update  
zhiru 已提交
86
        std::shared_ptr<MySQLConnectionPool> mysql_connection_pool_;
Z
zhiru 已提交
87 88
        bool safe_grab = false;

Z
zhiru 已提交
89
//        std::mutex connectionMutex_;
Z
zhiru 已提交
90 91 92 93 94 95
    }; // DBMetaImpl

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