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

#include <string>
#include <cstddef>
#include <vector>
11 12
#include <map>
#include <ctime>
X
Xu Peng 已提交
13 14
#include <memory>

X
Xu Peng 已提交
15 16
#include "Options.h"
#include "Status.h"
X
Xu Peng 已提交
17 18 19 20

namespace zilliz {
namespace vecwise {
namespace engine {
21 22 23
namespace meta {

typedef int DateT;
X
Xu Peng 已提交
24
const DateT EmptyDate = -1;
X
Xu Peng 已提交
25
typedef std::vector<DateT> DatesT;
X
Xu Peng 已提交
26 27 28 29 30 31 32 33 34 35 36 37

struct GroupSchema {
    size_t id;
    std::string group_id;
    size_t files_cnt = 0;
    uint16_t dimension;
    std::string location = "";
}; // GroupSchema


struct GroupFileSchema {
    typedef enum {
38
        NEW,
X
Xu Peng 已提交
39
        RAW,
X
Xu Peng 已提交
40
        TO_INDEX,
41 42
        INDEX,
        TO_DELETE,
X
Xu Peng 已提交
43 44 45 46 47
    } FILE_TYPE;

    size_t id;
    std::string group_id;
    std::string file_id;
48
    int file_type = NEW;
X
Xu Peng 已提交
49
    size_t rows;
X
Xu Peng 已提交
50
    DateT date = EmptyDate;
51
    uint16_t dimension;
X
Xu Peng 已提交
52
    std::string location = "";
53
    long updated_time;
X
Xu Peng 已提交
54 55 56
}; // GroupFileSchema

typedef std::vector<GroupFileSchema> GroupFilesSchema;
57
typedef std::map<DateT, GroupFilesSchema> DatePartionedGroupFilesSchema;
X
Xu Peng 已提交
58 59


X
Xu Peng 已提交
60
class Meta;
X
Xu Peng 已提交
61 62
class Meta {
public:
X
Xu Peng 已提交
63 64
    typedef std::shared_ptr<Meta> Ptr;

65 66
    virtual Status add_group(GroupSchema& group_info) = 0;
    virtual Status get_group(GroupSchema& group_info) = 0;
67 68
    virtual Status has_group(const std::string& group_id_, bool& has_or_not_) = 0;

X
Xu Peng 已提交
69
    virtual Status add_group_file(GroupFileSchema& group_file_info) = 0;
X
Xu Peng 已提交
70 71
    virtual Status delete_group_partitions(const std::string& group_id,
            const meta::DatesT& dates) = 0;
X
Xu Peng 已提交
72

73 74 75 76 77 78
    virtual Status has_group_file(const std::string& group_id_,
                                  const std::string& file_id_,
                                  bool& has_or_not_) = 0;
    virtual Status get_group_file(const std::string& group_id_,
                                  const std::string& file_id_,
                                  GroupFileSchema& group_file_info_) = 0;
79
    virtual Status update_group_file(GroupFileSchema& group_file_) = 0;
80 81

    virtual Status get_group_files(const std::string& group_id_,
82
                                   const int date_delta_,
83
                                   GroupFilesSchema& group_files_info_) = 0;
X
Xu Peng 已提交
84

85
    virtual Status update_files(GroupFilesSchema& files) = 0;
86

X
xj.lin 已提交
87
    virtual Status files_to_search(const std::string& group_id,
X
Xu Peng 已提交
88
                                   const DatesT& partition,
X
xj.lin 已提交
89 90
                                   DatePartionedGroupFilesSchema& files) = 0;

X
Xu Peng 已提交
91 92 93
    virtual Status files_to_merge(const std::string& group_id,
            DatePartionedGroupFilesSchema& files) = 0;

X
Xu Peng 已提交
94 95
    virtual Status files_to_index(GroupFilesSchema&) = 0;

X
Xu Peng 已提交
96
    virtual Status cleanup() = 0;
X
Xu Peng 已提交
97
    virtual Status cleanup_ttl_files(uint16_t) = 0;
X
Xu Peng 已提交
98

X
Xu Peng 已提交
99 100
    virtual Status drop_all() = 0;

X
Xu Peng 已提交
101 102
    virtual Status count(const std::string& group_id, long& result) = 0;

X
Xu Peng 已提交
103 104
    static DateT GetDate(const std::time_t& t, int day_delta);
    static DateT GetDate(int day_delta = 0);
105

X
Xu Peng 已提交
106 107
}; // MetaData

108
} // namespace meta
X
Xu Peng 已提交
109 110 111
} // namespace engine
} // namespace vecwise
} // namespace zilliz