ValidationUtil.h 2.3 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);

S
starlord 已提交
43
    static Status
S
starlord 已提交
44 45
    ValidateTableIndexNlist(int32_t nlist);

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

S
starlord 已提交
55
    static Status
S
starlord 已提交
56
    ValidateSearchNprobe(int64_t nprobe, const engine::meta::TableSchema& table_schema);
57

58 59 60
    static Status
    ValidatePartitionName(const std::string& partition_name);

G
groot 已提交
61 62 63
    static Status
    ValidatePartitionTags(const std::vector<std::string>& partition_tags);

S
starlord 已提交
64
    static Status
65
    ValidateGpuIndex(int32_t gpu_index);
66

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

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

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

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

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

S
starlord 已提交
84
    static Status
S
starlord 已提交
85
    ValidateDbURI(const std::string& uri);
86
};
J
jinhai 已提交
87

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