ValidationUtil.h 2.4 KB
Newer Older
1
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
J
jinhai 已提交
2
//
3 4
// Licensed 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
J
jinhai 已提交
5
//
6 7 8 9 10
// 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.
J
jinhai 已提交
11

J
jinhai 已提交
12 13
#pragma once

14
#include "db/meta/MetaTypes.h"
15
#include "utils/Json.h"
S
starlord 已提交
16
#include "utils/Status.h"
J
jinhai 已提交
17

S
starlord 已提交
18
#include <string>
G
groot 已提交
19
#include <vector>
S
starlord 已提交
20

J
jinhai 已提交
21 22 23
namespace milvus {
namespace server {

24
class ValidationUtil {
S
starlord 已提交
25
 private:
S
starlord 已提交
26 27
    ValidationUtil() = default;

S
starlord 已提交
28
 public:
S
starlord 已提交
29
    static Status
S
starlord 已提交
30
    ValidateTableName(const std::string& table_name);
J
jinhai 已提交
31

S
starlord 已提交
32
    static Status
33
    ValidateTableDimension(int64_t dimension);
J
jinhai 已提交
34

S
starlord 已提交
35
    static Status
36 37
    ValidateTableIndexType(int32_t index_type);

38 39 40
    static Status
    ValidateIndexParams(const milvus::json& index_params, const engine::meta::TableSchema& table_schema,
                        int32_t index_type);
G
groot 已提交
41

S
starlord 已提交
42
    static Status
43 44 45
    ValidateSearchParams(const milvus::json& search_params, const engine::meta::TableSchema& table_schema,
                         int64_t topk);

S
starlord 已提交
46
    static Status
47
    ValidateTableIndexFileSize(int64_t index_file_size);
S
starlord 已提交
48

S
starlord 已提交
49
    static Status
S
starlord 已提交
50 51
    ValidateTableIndexMetricType(int32_t metric_type);

S
starlord 已提交
52
    static Status
S
starlord 已提交
53
    ValidateSearchTopk(int64_t top_k, const engine::meta::TableSchema& table_schema);
54

55 56 57
    static Status
    ValidatePartitionName(const std::string& partition_name);

G
groot 已提交
58 59 60
    static Status
    ValidatePartitionTags(const std::vector<std::string>& partition_tags);

S
starlord 已提交
61
    static Status
62
    ValidateGpuIndex(int32_t gpu_index);
63

G
groot 已提交
64
#ifdef MILVUS_GPU_VERSION
S
starlord 已提交
65
    static Status
66
    GetGpuMemory(int32_t gpu_index, size_t& memory);
G
groot 已提交
67
#endif
68

S
starlord 已提交
69
    static Status
S
starlord 已提交
70
    ValidateIpAddress(const std::string& ip_address);
Z
zhiru 已提交
71

S
starlord 已提交
72
    static Status
S
starlord 已提交
73
    ValidateStringIsNumber(const std::string& str);
Z
zhiru 已提交
74

S
starlord 已提交
75
    static Status
S
starlord 已提交
76
    ValidateStringIsBool(const std::string& str);
Z
zhiru 已提交
77

S
starlord 已提交
78
    static Status
S
starlord 已提交
79
    ValidateStringIsFloat(const std::string& str);
Z
zhiru 已提交
80

S
starlord 已提交
81
    static Status
S
starlord 已提交
82
    ValidateDbURI(const std::string& uri);
83 84 85

    static Status
    ValidateStoragePath(const std::string& path);
86
};
J
jinhai 已提交
87

S
starlord 已提交
88 89
}  // namespace server
}  // namespace milvus