diff --git a/include/abstract_index.h b/include/abstract_index.h index 7c84a8ec9..3f7dae7cf 100644 --- a/include/abstract_index.h +++ b/include/abstract_index.h @@ -80,8 +80,8 @@ class AbstractIndex float *distances); // insert points with labels, labels should be present for filtered index - template - int insert_point(const data_type *point, const tag_type tag, const std::vector &labels); + template + int insert_point(const data_type *point, const tag_type tag, const std::vector &labels); // insert point for unfiltered index build. do not use with filtered index template int insert_point(const data_type *point, const tag_type tag); @@ -116,7 +116,7 @@ class AbstractIndex virtual std::pair _search_with_filters(const DataType &query, const std::string &filter_label, const size_t K, const uint32_t L, std::any &indices, float *distances) = 0; - virtual int _insert_point(const DataType &data_point, const TagType tag, Labelvector &labels) = 0; + virtual int _insert_point(const DataType &data_point, const TagType tag, const std::vector &labels) = 0; virtual int _insert_point(const DataType &data_point, const TagType tag) = 0; virtual int _lazy_delete(const TagType &tag) = 0; virtual void _lazy_delete(TagVector &tags, TagVector &failed_tags) = 0; diff --git a/include/index.h b/include/index.h index 46a771e67..05c868e31 100644 --- a/include/index.h +++ b/include/index.h @@ -328,7 +328,7 @@ template clas float *distances) override; virtual int _insert_point(const DataType &data_point, const TagType tag) override; - virtual int _insert_point(const DataType &data_point, const TagType tag, Labelvector &labels) override; + virtual int _insert_point(const DataType &data_point, const TagType tag, const std::vector &labels) override; virtual int _lazy_delete(const TagType &tag) override; diff --git a/src/abstract_index.cpp b/src/abstract_index.cpp index 7550bda3a..6047170a9 100644 --- a/src/abstract_index.cpp +++ b/src/abstract_index.cpp @@ -57,13 +57,12 @@ int AbstractIndex::insert_point(const data_type *point, const tag_type tag) return this->_insert_point(any_point, any_tag); } -template -int AbstractIndex::insert_point(const data_type *point, const tag_type tag, const std::vector &labels) +template +int AbstractIndex::insert_point(const data_type *point, const tag_type tag, const std::vector& labels) { auto any_point = std::any(point); auto any_tag = std::any(tag); - auto any_labels = Labelvector(labels); - return this->_insert_point(any_point, any_tag, any_labels); + return this->_insert_point(any_point, any_tag, labels); } template int AbstractIndex::lazy_delete(const tag_type &tag) @@ -259,75 +258,41 @@ template DISKANN_DLLEXPORT int AbstractIndex::insert_point(c template DISKANN_DLLEXPORT int AbstractIndex::insert_point(const uint8_t* point, const tag_uint128 tag); template DISKANN_DLLEXPORT int AbstractIndex::insert_point(const int8_t* point, const tag_uint128 tag); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float *point, const int32_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t *point, const int32_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t *point, const int32_t tag, const std::vector &labels); - -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float *point, const uint32_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t *point, const uint32_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t *point, const uint32_t tag, const std::vector &labels); - -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float *point, const int64_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t *point, const int64_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t *point, const int64_t tag, const std::vector &labels); - -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float *point, const uint64_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t *point, const uint64_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t *point, const uint64_t tag, const std::vector &labels); - -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float* point, const tag_uint128 tag, const std::vector& labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t* point, const tag_uint128 tag, const std::vector& labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t* point, const tag_uint128 tag, const std::vector& labels); - -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float *point, const int32_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t *point, const int32_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t *point, const int32_t tag, const std::vector &labels); - -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float *point, const uint32_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t *point, const uint32_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t *point, const uint32_t tag, const std::vector &labels); - -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float *point, const int64_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t *point, const int64_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t *point, const int64_t tag, const std::vector &labels); - -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float *point, const uint64_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t *point, const uint64_t tag, const std::vector &labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t *point, const uint64_t tag, const std::vector &labels); - -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const float* point, const tag_uint128 tag, const std::vector& labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const uint8_t* point, const tag_uint128 tag, const std::vector& labels); -template DISKANN_DLLEXPORT int AbstractIndex::insert_point( - const int8_t* point, const tag_uint128 tag, const std::vector& labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const float *point, const int32_t tag, const std::vector &labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const uint8_t *point, const int32_t tag, const std::vector &labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const int8_t *point, const int32_t tag, const std::vector &labels); + +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const float *point, const uint32_t tag, const std::vector &labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const uint8_t *point, const uint32_t tag, const std::vector &labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const int8_t *point, const uint32_t tag, const std::vector &labels); + +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const float *point, const int64_t tag, const std::vector &labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const uint8_t *point, const int64_t tag, const std::vector &labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const int8_t *point, const int64_t tag, const std::vector &labels); + +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const float *point, const uint64_t tag, const std::vector &labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const uint8_t *point, const uint64_t tag, const std::vector &labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const int8_t *point, const uint64_t tag, const std::vector &labels); + +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const float* point, const tag_uint128 tag, const std::vector& labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const uint8_t* point, const tag_uint128 tag, const std::vector& labels); +template DISKANN_DLLEXPORT int AbstractIndex::insert_point( + const int8_t* point, const tag_uint128 tag, const std::vector& labels); + template DISKANN_DLLEXPORT int AbstractIndex::lazy_delete(const int32_t &tag); template DISKANN_DLLEXPORT int AbstractIndex::lazy_delete(const uint32_t &tag); diff --git a/src/index.cpp b/src/index.cpp index 1beb23b08..dd732b9c8 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -3085,12 +3085,18 @@ int Index::_insert_point(const DataType &point, const TagType t } template -int Index::_insert_point(const DataType &point, const TagType tag, Labelvector &labels) +int Index::_insert_point(const DataType &point, const TagType tag, const std::vector& labels) { try { - return this->insert_point(std::any_cast(point), std::any_cast(tag), - labels.get>()); + std::vector converted_labels; + converted_labels.reserve(labels.size()); + for (const auto& label : labels) + { + auto converted_label = this->get_converted_label(label); + converted_labels.push_back(converted_label); + } + return this->insert_point(std::any_cast(point), std::any_cast(tag), converted_labels); } catch (const std::bad_any_cast &anycast_e) {