mirror of https://github.com/milvus-io/milvus.git
enhance: remove -inl.h files (#28674)
issue: https://github.com/milvus-io/milvus/issues/28673 Move template implementations from -inl.h to .cpp file and make explicit instantiation Signed-off-by: sunby <sunbingyi1992@gmail.com>pull/28364/head
parent
31f442915b
commit
e5ce385ffd
|
@ -15,6 +15,8 @@ set(INDEX_FILES
|
|||
VectorMemIndex.cpp
|
||||
IndexFactory.cpp
|
||||
VectorDiskIndex.cpp
|
||||
ScalarIndex.cpp
|
||||
ScalarIndexSort.cpp
|
||||
)
|
||||
|
||||
milvus_add_pkg_config("milvus_index")
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
// 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.
|
||||
|
||||
#include <string>
|
||||
#include "index/ScalarIndexSort.h"
|
||||
#include "index/StringIndexMarisa.h"
|
||||
#include "index/BoolIndex.h"
|
||||
|
||||
namespace milvus::index {
|
||||
|
||||
template <typename T>
|
||||
inline ScalarIndexPtr<T>
|
||||
IndexFactory::CreateScalarIndex(
|
||||
const IndexType& index_type,
|
||||
const storage::FileManagerContext& file_manager_context) {
|
||||
return CreateScalarIndexSort<T>(file_manager_context);
|
||||
}
|
||||
|
||||
// template <>
|
||||
// inline ScalarIndexPtr<bool>
|
||||
// IndexFactory::CreateScalarIndex(const IndexType& index_type) {
|
||||
// return CreateBoolIndex();
|
||||
//}
|
||||
|
||||
template <>
|
||||
inline ScalarIndexPtr<std::string>
|
||||
IndexFactory::CreateScalarIndex(
|
||||
const IndexType& index_type,
|
||||
const storage::FileManagerContext& file_manager_context) {
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
return CreateStringIndexMarisa(file_manager_context);
|
||||
#else
|
||||
throw std::runtime_error("unsupported platform");
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace milvus::index
|
|
@ -21,9 +21,39 @@
|
|||
#include "knowhere/utils.h"
|
||||
|
||||
#include "index/VectorDiskIndex.h"
|
||||
#include "index/ScalarIndexSort.h"
|
||||
#include "index/StringIndexMarisa.h"
|
||||
#include "index/BoolIndex.h"
|
||||
|
||||
namespace milvus::index {
|
||||
|
||||
template <typename T>
|
||||
ScalarIndexPtr<T>
|
||||
IndexFactory::CreateScalarIndex(
|
||||
const IndexType& index_type,
|
||||
const storage::FileManagerContext& file_manager_context) {
|
||||
return CreateScalarIndexSort<T>(file_manager_context);
|
||||
}
|
||||
|
||||
// template <>
|
||||
// inline ScalarIndexPtr<bool>
|
||||
// IndexFactory::CreateScalarIndex(const IndexType& index_type) {
|
||||
// return CreateBoolIndex();
|
||||
//}
|
||||
//
|
||||
|
||||
template <>
|
||||
ScalarIndexPtr<std::string>
|
||||
IndexFactory::CreateScalarIndex<std::string>(
|
||||
const IndexType& index_type,
|
||||
const storage::FileManagerContext& file_manager_context) {
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
return CreateStringIndexMarisa(file_manager_context);
|
||||
#else
|
||||
throw std::runtime_error("unsupported platform");
|
||||
#endif
|
||||
}
|
||||
|
||||
IndexBasePtr
|
||||
IndexFactory::CreateIndex(
|
||||
const CreateIndexInfo& create_index_info,
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
#include "index/IndexInfo.h"
|
||||
#include "storage/Types.h"
|
||||
#include "storage/FileManager.h"
|
||||
#include "index/StringIndexMarisa.h"
|
||||
#include "index/ScalarIndexSort.h"
|
||||
#include "index/StringIndexMarisa.h"
|
||||
#include "index/BoolIndex.h"
|
||||
|
||||
namespace milvus::index {
|
||||
|
||||
|
@ -69,6 +73,9 @@ class IndexFactory {
|
|||
storage::FileManagerContext());
|
||||
};
|
||||
|
||||
template <>
|
||||
ScalarIndexPtr<std::string>
|
||||
IndexFactory::CreateScalarIndex<std::string>(
|
||||
const IndexType& index_type,
|
||||
const storage::FileManagerContext& file_manager_context);
|
||||
} // namespace milvus::index
|
||||
|
||||
#include "index/IndexFactory-inl.h"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "index/Meta.h"
|
||||
#include "knowhere/dataset.h"
|
||||
#include "common/Types.h"
|
||||
#include "index/ScalarIndex.h"
|
||||
|
||||
namespace milvus::index {
|
||||
template <typename T>
|
||||
|
@ -71,7 +72,7 @@ ScalarIndex<T>::Query(const DatasetPtr& dataset) {
|
|||
}
|
||||
|
||||
template <>
|
||||
inline void
|
||||
void
|
||||
ScalarIndex<std::string>::BuildWithRawData(size_t n,
|
||||
const void* values,
|
||||
const Config& config) {
|
||||
|
@ -85,7 +86,7 @@ ScalarIndex<std::string>::BuildWithRawData(size_t n,
|
|||
}
|
||||
|
||||
template <>
|
||||
inline void
|
||||
void
|
||||
ScalarIndex<bool>::BuildWithRawData(size_t n,
|
||||
const void* values,
|
||||
const Config& config) {
|
||||
|
@ -96,7 +97,7 @@ ScalarIndex<bool>::BuildWithRawData(size_t n,
|
|||
}
|
||||
|
||||
template <>
|
||||
inline void
|
||||
void
|
||||
ScalarIndex<int8_t>::BuildWithRawData(size_t n,
|
||||
const void* values,
|
||||
const Config& config) {
|
||||
|
@ -105,7 +106,7 @@ ScalarIndex<int8_t>::BuildWithRawData(size_t n,
|
|||
}
|
||||
|
||||
template <>
|
||||
inline void
|
||||
void
|
||||
ScalarIndex<int16_t>::BuildWithRawData(size_t n,
|
||||
const void* values,
|
||||
const Config& config) {
|
||||
|
@ -114,7 +115,7 @@ ScalarIndex<int16_t>::BuildWithRawData(size_t n,
|
|||
}
|
||||
|
||||
template <>
|
||||
inline void
|
||||
void
|
||||
ScalarIndex<int32_t>::BuildWithRawData(size_t n,
|
||||
const void* values,
|
||||
const Config& config) {
|
||||
|
@ -123,7 +124,7 @@ ScalarIndex<int32_t>::BuildWithRawData(size_t n,
|
|||
}
|
||||
|
||||
template <>
|
||||
inline void
|
||||
void
|
||||
ScalarIndex<int64_t>::BuildWithRawData(size_t n,
|
||||
const void* values,
|
||||
const Config& config) {
|
||||
|
@ -132,7 +133,7 @@ ScalarIndex<int64_t>::BuildWithRawData(size_t n,
|
|||
}
|
||||
|
||||
template <>
|
||||
inline void
|
||||
void
|
||||
ScalarIndex<float>::BuildWithRawData(size_t n,
|
||||
const void* values,
|
||||
const Config& config) {
|
||||
|
@ -141,7 +142,7 @@ ScalarIndex<float>::BuildWithRawData(size_t n,
|
|||
}
|
||||
|
||||
template <>
|
||||
inline void
|
||||
void
|
||||
ScalarIndex<double>::BuildWithRawData(size_t n,
|
||||
const void* values,
|
||||
const Config& config) {
|
||||
|
@ -149,4 +150,12 @@ ScalarIndex<double>::BuildWithRawData(size_t n,
|
|||
Build(n, data);
|
||||
}
|
||||
|
||||
template class ScalarIndex<bool>;
|
||||
template class ScalarIndex<int8_t>;
|
||||
template class ScalarIndex<int16_t>;
|
||||
template class ScalarIndex<int32_t>;
|
||||
template class ScalarIndex<int64_t>;
|
||||
template class ScalarIndex<float>;
|
||||
template class ScalarIndex<double>;
|
||||
template class ScalarIndex<std::string>;
|
||||
} // namespace milvus::index
|
|
@ -76,5 +76,3 @@ template <typename T>
|
|||
using ScalarIndexPtr = std::unique_ptr<ScalarIndex<T>>;
|
||||
|
||||
} // namespace milvus::index
|
||||
|
||||
#include "index/ScalarIndex-inl.h"
|
||||
|
|
|
@ -26,11 +26,12 @@
|
|||
#include "common/Slice.h"
|
||||
#include "common/Types.h"
|
||||
#include "index/Utils.h"
|
||||
#include "index/ScalarIndexSort.h"
|
||||
|
||||
namespace milvus::index {
|
||||
|
||||
template <typename T>
|
||||
inline ScalarIndexSort<T>::ScalarIndexSort(
|
||||
ScalarIndexSort<T>::ScalarIndexSort(
|
||||
const storage::FileManagerContext& file_manager_context)
|
||||
: is_built_(false), data_() {
|
||||
if (file_manager_context.Valid()) {
|
||||
|
@ -41,7 +42,7 @@ inline ScalarIndexSort<T>::ScalarIndexSort(
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline void
|
||||
void
|
||||
ScalarIndexSort<T>::Build(const Config& config) {
|
||||
if (is_built_)
|
||||
return;
|
||||
|
@ -81,7 +82,7 @@ ScalarIndexSort<T>::Build(const Config& config) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline void
|
||||
void
|
||||
ScalarIndexSort<T>::Build(size_t n, const T* values) {
|
||||
if (is_built_)
|
||||
return;
|
||||
|
@ -103,7 +104,7 @@ ScalarIndexSort<T>::Build(size_t n, const T* values) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline BinarySet
|
||||
BinarySet
|
||||
ScalarIndexSort<T>::Serialize(const Config& config) {
|
||||
AssertInfo(is_built_, "index has not been built");
|
||||
|
||||
|
@ -125,7 +126,7 @@ ScalarIndexSort<T>::Serialize(const Config& config) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline BinarySet
|
||||
BinarySet
|
||||
ScalarIndexSort<T>::Upload(const Config& config) {
|
||||
auto binary_set = Serialize(config);
|
||||
file_manager_->AddFile(binary_set);
|
||||
|
@ -140,7 +141,7 @@ ScalarIndexSort<T>::Upload(const Config& config) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline void
|
||||
void
|
||||
ScalarIndexSort<T>::LoadWithoutAssemble(const BinarySet& index_binary,
|
||||
const Config& config) {
|
||||
size_t index_size;
|
||||
|
@ -158,14 +159,14 @@ ScalarIndexSort<T>::LoadWithoutAssemble(const BinarySet& index_binary,
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline void
|
||||
void
|
||||
ScalarIndexSort<T>::Load(const BinarySet& index_binary, const Config& config) {
|
||||
milvus::Assemble(const_cast<BinarySet&>(index_binary));
|
||||
LoadWithoutAssemble(index_binary, config);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void
|
||||
void
|
||||
ScalarIndexSort<T>::Load(const Config& config) {
|
||||
auto index_files =
|
||||
GetValueFromConfig<std::vector<std::string>>(config, "index_files");
|
||||
|
@ -186,7 +187,7 @@ ScalarIndexSort<T>::Load(const Config& config) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline const TargetBitmap
|
||||
const TargetBitmap
|
||||
ScalarIndexSort<T>::In(const size_t n, const T* values) {
|
||||
AssertInfo(is_built_, "index has not been built");
|
||||
TargetBitmap bitset(data_.size());
|
||||
|
@ -208,7 +209,7 @@ ScalarIndexSort<T>::In(const size_t n, const T* values) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline const TargetBitmap
|
||||
const TargetBitmap
|
||||
ScalarIndexSort<T>::NotIn(const size_t n, const T* values) {
|
||||
AssertInfo(is_built_, "index has not been built");
|
||||
TargetBitmap bitset(data_.size(), true);
|
||||
|
@ -230,7 +231,7 @@ ScalarIndexSort<T>::NotIn(const size_t n, const T* values) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline const TargetBitmap
|
||||
const TargetBitmap
|
||||
ScalarIndexSort<T>::Range(const T value, const OpType op) {
|
||||
AssertInfo(is_built_, "index has not been built");
|
||||
TargetBitmap bitset(data_.size());
|
||||
|
@ -267,7 +268,7 @@ ScalarIndexSort<T>::Range(const T value, const OpType op) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline const TargetBitmap
|
||||
const TargetBitmap
|
||||
ScalarIndexSort<T>::Range(T lower_bound_value,
|
||||
bool lb_inclusive,
|
||||
T upper_bound_value,
|
||||
|
@ -305,7 +306,7 @@ ScalarIndexSort<T>::Range(T lower_bound_value,
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline T
|
||||
T
|
||||
ScalarIndexSort<T>::Reverse_Lookup(size_t idx) const {
|
||||
AssertInfo(idx < idx_to_offsets_.size(), "out of range of total count");
|
||||
AssertInfo(is_built_, "index has not been built");
|
||||
|
@ -315,7 +316,7 @@ ScalarIndexSort<T>::Reverse_Lookup(size_t idx) const {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool
|
||||
bool
|
||||
ScalarIndexSort<T>::ShouldSkip(const T lower_value,
|
||||
const T upper_value,
|
||||
const milvus::OpType op) {
|
||||
|
@ -357,4 +358,12 @@ ScalarIndexSort<T>::ShouldSkip(const T lower_value,
|
|||
return true;
|
||||
}
|
||||
|
||||
template class ScalarIndexSort<bool>;
|
||||
template class ScalarIndexSort<int8_t>;
|
||||
template class ScalarIndexSort<int16_t>;
|
||||
template class ScalarIndexSort<int32_t>;
|
||||
template class ScalarIndexSort<int64_t>;
|
||||
template class ScalarIndexSort<float>;
|
||||
template class ScalarIndexSort<double>;
|
||||
template class ScalarIndexSort<std::string>;
|
||||
} // namespace milvus::index
|
|
@ -113,8 +113,6 @@ using ScalarIndexSortPtr = std::unique_ptr<ScalarIndexSort<T>>;
|
|||
|
||||
} // namespace milvus::index
|
||||
|
||||
#include "index/ScalarIndexSort-inl.h"
|
||||
|
||||
namespace milvus::index {
|
||||
template <typename T>
|
||||
inline ScalarIndexSortPtr<T>
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "query/PlanProto.h"
|
||||
#include "segcore/SkipIndex.h"
|
||||
#include "simd/hook.h"
|
||||
#include "index/Meta.h"
|
||||
|
||||
namespace milvus::query {
|
||||
// THIS CONTAINS EXTRA BODY FOR VISITOR
|
||||
|
|
Loading…
Reference in New Issue