// Licensed to the LF AI & Data foundation 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. #pragma once #include #include #include #include #include #include #include #include #include #include #include "common/Types.h" #include "common/FieldData.h" #include "index/IndexInfo.h" #include "storage/Types.h" namespace milvus::index { size_t get_file_size(int fd); std::vector NM_List(); std::vector BIN_List(); std::vector> unsupported_index_combinations(); bool is_in_bin_list(const IndexType& index_type); bool is_in_nm_list(const IndexType& index_type); bool is_unsupported(const IndexType& index_type, const MetricType& metric_type); bool CheckKeyInConfig(const Config& cfg, const std::string& key); void ParseFromString(google::protobuf::Message& params, const std::string& str); template void inline CheckParameter(Config& conf, const std::string& key, std::function fn, std::optional default_v) { if (!conf.contains(key)) { if (default_v.has_value()) { conf[key] = default_v.value(); } } else { auto value = conf[key]; conf[key] = fn(value); } } template inline std::optional GetValueFromConfig(const Config& cfg, const std::string& key) { if (cfg.contains(key)) { return cfg.at(key).get(); } return std::nullopt; } template inline void SetValueToConfig(Config& cfg, const std::string& key, const T value) { cfg[key] = value; } int64_t GetDimFromConfig(const Config& config); std::string GetMetricTypeFromConfig(const Config& config); std::string GetIndexTypeFromConfig(const Config& config); IndexVersion GetIndexEngineVersionFromConfig(const Config& config); storage::FieldDataMeta GetFieldDataMetaFromConfig(const Config& config); storage::IndexMeta GetIndexMetaFromConfig(const Config& config); Config ParseConfigFromIndexParams( const std::map& index_params); void AssembleIndexDatas(std::map& index_datas); void AssembleIndexDatas(std::map& index_datas, std::unordered_map& result); // On Linux, read() (and similar system calls) will transfer at most 0x7ffff000 (2,147,479,552) bytes once void ReadDataFromFD(int fd, void* buf, size_t size, size_t chunk_size = 0x7ffff000); } // namespace milvus::index