Meta.h 2.6 KB
Newer Older
X
Xu Peng 已提交
1 2 3 4 5
#pragma once

#include <string>
#include <cstddef>
#include <vector>
6 7
#include <map>
#include <ctime>
X
Xu Peng 已提交
8 9
#include "Options.h"
#include "Status.h"
X
Xu Peng 已提交
10 11 12 13

namespace zilliz {
namespace vecwise {
namespace engine {
14 15 16
namespace meta {

typedef int DateT;
X
Xu Peng 已提交
17
const DateT EmptyDate = -1;
X
Xu Peng 已提交
18 19 20 21 22 23 24 25 26 27 28 29

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 {
30
        NEW,
X
Xu Peng 已提交
31
        RAW,
X
Xu Peng 已提交
32
        TO_INDEX,
33 34
        INDEX,
        TO_DELETE,
X
Xu Peng 已提交
35 36 37 38 39
    } FILE_TYPE;

    size_t id;
    std::string group_id;
    std::string file_id;
40
    int file_type = NEW;
X
Xu Peng 已提交
41
    size_t rows;
X
Xu Peng 已提交
42
    DateT date = EmptyDate;
43
    uint16_t dimension;
X
Xu Peng 已提交
44
    std::string location = "";
45
    long updated_time;
X
Xu Peng 已提交
46 47 48
}; // GroupFileSchema

typedef std::vector<GroupFileSchema> GroupFilesSchema;
49
typedef std::map<DateT, GroupFilesSchema> DatePartionedGroupFilesSchema;
X
Xu Peng 已提交
50 51 52 53


class Meta {
public:
54 55
    virtual Status add_group(GroupSchema& group_info) = 0;
    virtual Status get_group(GroupSchema& group_info) = 0;
56 57
    virtual Status has_group(const std::string& group_id_, bool& has_or_not_) = 0;

X
Xu Peng 已提交
58
    virtual Status add_group_file(GroupFileSchema& group_file_info) = 0;
X
Xu Peng 已提交
59

60 61 62 63 64 65
    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;
66
    virtual Status update_group_file(GroupFileSchema& group_file_) = 0;
67 68

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

72
    virtual Status update_files(GroupFilesSchema& files) = 0;
73

X
xj.lin 已提交
74 75 76 77
    virtual Status files_to_search(const std::string& group_id,
                                   std::vector<DateT> partition,
                                   DatePartionedGroupFilesSchema& files) = 0;

X
Xu Peng 已提交
78 79 80
    virtual Status files_to_merge(const std::string& group_id,
            DatePartionedGroupFilesSchema& files) = 0;

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

X
Xu Peng 已提交
83
    virtual Status cleanup() = 0;
X
Xu Peng 已提交
84
    virtual Status cleanup_ttl_files(uint16_t) = 0;
X
Xu Peng 已提交
85

X
Xu Peng 已提交
86 87
    virtual Status drop_all() = 0;

88 89 90
    static DateT GetDate(const std::time_t& t);
    static DateT GetDate();

X
Xu Peng 已提交
91 92
}; // MetaData

93
} // namespace meta
X
Xu Peng 已提交
94 95 96
} // namespace engine
} // namespace vecwise
} // namespace zilliz