ValidationUtil.h 2.5 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.

J
jinhai 已提交
18 19
#pragma once

20
#include "db/meta/MetaTypes.h"
S
starlord 已提交
21
#include "utils/Status.h"
J
jinhai 已提交
22

S
starlord 已提交
23
#include <string>
G
groot 已提交
24
#include <vector>
S
starlord 已提交
25

J
jinhai 已提交
26 27 28
namespace milvus {
namespace server {

29
class ValidationUtil {
S
starlord 已提交
30
 private:
S
starlord 已提交
31 32
    ValidationUtil() = default;

S
starlord 已提交
33
 public:
S
starlord 已提交
34
    static Status
S
starlord 已提交
35
    ValidateTableName(const std::string& table_name);
J
jinhai 已提交
36

S
starlord 已提交
37
    static Status
38
    ValidateTableDimension(int64_t dimension);
J
jinhai 已提交
39

S
starlord 已提交
40
    static Status
41 42
    ValidateTableIndexType(int32_t index_type);

G
groot 已提交
43 44 45
    static bool
    IsBinaryIndexType(int32_t index_type);

S
starlord 已提交
46
    static Status
S
starlord 已提交
47 48
    ValidateTableIndexNlist(int32_t nlist);

S
starlord 已提交
49
    static Status
50
    ValidateTableIndexFileSize(int64_t index_file_size);
S
starlord 已提交
51

S
starlord 已提交
52
    static Status
S
starlord 已提交
53 54
    ValidateTableIndexMetricType(int32_t metric_type);

G
groot 已提交
55 56 57
    static bool
    IsBinaryMetricType(int32_t metric_type);

S
starlord 已提交
58
    static Status
S
starlord 已提交
59
    ValidateSearchTopk(int64_t top_k, const engine::meta::TableSchema& table_schema);
60

S
starlord 已提交
61
    static Status
S
starlord 已提交
62
    ValidateSearchNprobe(int64_t nprobe, const engine::meta::TableSchema& table_schema);
63

64 65 66
    static Status
    ValidatePartitionName(const std::string& partition_name);

G
groot 已提交
67 68 69
    static Status
    ValidatePartitionTags(const std::vector<std::string>& partition_tags);

S
starlord 已提交
70
    static Status
71
    ValidateGpuIndex(int32_t gpu_index);
72

G
groot 已提交
73
#ifdef MILVUS_GPU_VERSION
S
starlord 已提交
74
    static Status
75
    GetGpuMemory(int32_t gpu_index, size_t& memory);
G
groot 已提交
76
#endif
77

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

S
starlord 已提交
81
    static Status
S
starlord 已提交
82
    ValidateStringIsNumber(const std::string& str);
Z
zhiru 已提交
83

S
starlord 已提交
84
    static Status
S
starlord 已提交
85
    ValidateStringIsBool(const std::string& str);
Z
zhiru 已提交
86

S
starlord 已提交
87
    static Status
S
starlord 已提交
88
    ValidateStringIsFloat(const std::string& str);
Z
zhiru 已提交
89

S
starlord 已提交
90
    static Status
S
starlord 已提交
91
    ValidateDbURI(const std::string& uri);
92
};
J
jinhai 已提交
93

S
starlord 已提交
94 95
}  // namespace server
}  // namespace milvus