MetaTypes.h 3.1 KB
Newer Older
J
jinhai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

X
Xu Peng 已提交
18 19
#pragma once

S
starlord 已提交
20
#include "db/Constants.h"
S
starlord 已提交
21
#include "db/engine/ExecutionEngine.h"
G
groot 已提交
22
#include "src/config.h"
G
groot 已提交
23

X
Xu Peng 已提交
24
#include <map>
S
starlord 已提交
25
#include <memory>
S
starlord 已提交
26 27
#include <string>
#include <vector>
X
Xu Peng 已提交
28

J
jinhai 已提交
29
namespace milvus {
X
Xu Peng 已提交
30 31 32
namespace engine {
namespace meta {

S
starlord 已提交
33
constexpr int32_t DEFAULT_ENGINE_TYPE = (int)EngineType::FAISS_IDMAP;
S
starlord 已提交
34
constexpr int32_t DEFAULT_NLIST = 16384;
S
starlord 已提交
35
constexpr int32_t DEFAULT_METRIC_TYPE = (int)MetricType::L2;
36
constexpr int32_t DEFAULT_INDEX_FILE_SIZE = ONE_GB;
G
groot 已提交
37
constexpr char CURRENT_VERSION[] = MILVUS_VERSION;
S
starlord 已提交
38

39
constexpr int64_t FLAG_MASK_NO_USERID = 0x1;
S
starlord 已提交
40
constexpr int64_t FLAG_MASK_HAS_USERID = 0x1 << 1;
S
starlord 已提交
41

S
starlord 已提交
42
using DateT = int;
X
Xu Peng 已提交
43
const DateT EmptyDate = -1;
W
wxyu 已提交
44
using DatesT = std::vector<DateT>;
X
Xu Peng 已提交
45

46
struct TableSchema {
G
groot 已提交
47 48 49 50 51 52
    typedef enum {
        NORMAL,
        TO_DELETE,
    } TABLE_STATE;

    size_t id_ = 0;
G
groot 已提交
53
    std::string table_id_;
S
starlord 已提交
54
    int32_t state_ = (int)NORMAL;
G
groot 已提交
55
    uint16_t dimension_ = 0;
56
    int64_t created_on_ = 0;
S
starlord 已提交
57
    int64_t flag_ = 0;
S
starlord 已提交
58
    int64_t index_file_size_ = DEFAULT_INDEX_FILE_SIZE;
S
starlord 已提交
59 60 61
    int32_t engine_type_ = DEFAULT_ENGINE_TYPE;
    int32_t nlist_ = DEFAULT_NLIST;
    int32_t metric_type_ = DEFAULT_METRIC_TYPE;
G
groot 已提交
62 63 64
    std::string owner_table_;
    std::string partition_tag_;
    std::string version_ = CURRENT_VERSION;
S
starlord 已提交
65
};  // TableSchema
X
Xu Peng 已提交
66

67
struct TableFileSchema {
X
Xu Peng 已提交
68 69 70 71 72 73
    typedef enum {
        NEW,
        RAW,
        TO_INDEX,
        INDEX,
        TO_DELETE,
74 75
        NEW_MERGE,
        NEW_INDEX,
76
        BACKUP,
X
Xu Peng 已提交
77 78
    } FILE_TYPE;

G
groot 已提交
79
    size_t id_ = 0;
G
groot 已提交
80 81
    std::string table_id_;
    std::string file_id_;
82 83 84
    int32_t file_type_ = NEW;
    size_t file_size_ = 0;
    size_t row_count_ = 0;
G
groot 已提交
85
    DateT date_ = EmptyDate;
G
groot 已提交
86
    uint16_t dimension_ = 0;
G
groot 已提交
87
    std::string location_;
88 89
    int64_t updated_time_ = 0;
    int64_t created_on_ = 0;
S
starlord 已提交
90
    int64_t index_file_size_ = DEFAULT_INDEX_FILE_SIZE;  // not persist to meta
S
starlord 已提交
91
    int32_t engine_type_ = DEFAULT_ENGINE_TYPE;
S
starlord 已提交
92 93 94
    int32_t nlist_ = DEFAULT_NLIST;              // not persist to meta
    int32_t metric_type_ = DEFAULT_METRIC_TYPE;  // not persist to meta
};                                               // TableFileSchema
X
Xu Peng 已提交
95

W
wxyu 已提交
96 97 98
using TableFileSchemaPtr = std::shared_ptr<meta::TableFileSchema>;
using TableFilesSchema = std::vector<TableFileSchema>;
using DatePartionedTableFilesSchema = std::map<DateT, TableFilesSchema>;
X
Xu Peng 已提交
99

S
starlord 已提交
100 101 102
}  // namespace meta
}  // namespace engine
}  // namespace milvus