Meta.h 3.4 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

struct GroupSchema {
    size_t id;
    std::string group_id;
    size_t files_cnt = 0;
    uint16_t dimension;
    std::string location = "";
X
Xu Peng 已提交
33
    long created_on;
X
Xu Peng 已提交
34 35 36 37 38
}; // GroupSchema


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

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

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


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

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

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

75 76 77 78 79 80
    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;
81
    virtual Status update_group_file(GroupFileSchema& group_file_) = 0;
82 83

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

87
    virtual Status update_files(GroupFilesSchema& files) = 0;
88

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

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

X
Xu Peng 已提交
96 97
    virtual Status archive_files() = 0;

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

X
Xu Peng 已提交
100
    virtual Status cleanup() = 0;
X
Xu Peng 已提交
101
    virtual Status cleanup_ttl_files(uint16_t) = 0;
X
Xu Peng 已提交
102

X
Xu Peng 已提交
103 104
    virtual Status drop_all() = 0;

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

X
Xu Peng 已提交
107 108 109
    static DateT GetDate(const std::time_t& t, int day_delta = 0);
    static DateT GetDate();
    static DateT GetDateWithDelta(int day_delta);
110

X
Xu Peng 已提交
111 112
}; // MetaData

113
} // namespace meta
X
Xu Peng 已提交
114 115 116
} // namespace engine
} // namespace vecwise
} // namespace zilliz