From 70c0f0f3ed15f6b7aa9b1951ea9d7676219b298f Mon Sep 17 00:00:00 2001 From: Paris Morgan Date: Wed, 16 Oct 2024 11:23:54 -0700 Subject: [PATCH] fix AddressSanitizer: FPE, fix incorrect type in create() --- .../src/tiledb/vector_search/ingestion.py | 2 +- src/include/index/ivf_pq_group.h | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apis/python/src/tiledb/vector_search/ingestion.py b/apis/python/src/tiledb/vector_search/ingestion.py index 30f04a85d..081f9276a 100644 --- a/apis/python/src/tiledb/vector_search/ingestion.py +++ b/apis/python/src/tiledb/vector_search/ingestion.py @@ -3070,7 +3070,7 @@ def consolidate_and_vacuum( uri=index_group_uri, dimensions=dimensions, vector_type=vector_type, - num_subspaces=num_subspaces, + num_subspaces=int(num_subspaces), partitions=partitions, config=config, storage_version=storage_version, diff --git a/src/include/index/ivf_pq_group.h b/src/include/index/ivf_pq_group.h index 6d710f709..c4857c97b 100644 --- a/src/include/index/ivf_pq_group.h +++ b/src/include/index/ivf_pq_group.h @@ -77,6 +77,16 @@ class ivf_pq_group : public base_index_group { int32_t tile_size{0}; tiledb_filter_type_t default_compression; + int32_t compute_tile_size() const { + if (this->get_dimensions() == 0) { + return (int32_t)(tile_size_bytes / + sizeof(typename index_type::feature_type) / 100); + } + return (int32_t)(tile_size_bytes / + sizeof(typename index_type::feature_type) / + this->get_dimensions()); + } + public: ivf_pq_group( const tiledb::Context& ctx, @@ -103,9 +113,7 @@ class ivf_pq_group : public base_index_group { // If we are creating a new group, we set these before load(). if (rw == TILEDB_WRITE) { - tile_size = (int32_t)(tile_size_bytes / - sizeof(typename index_type::feature_type) / - this->get_dimensions()); + tile_size = compute_tile_size(); default_compression = string_to_filter( storage_formats[this->version_]["default_attr_filters"]); } @@ -116,9 +124,7 @@ class ivf_pq_group : public base_index_group { // Else if we are reading a group, we set these after load(). if (rw == TILEDB_READ) { - tile_size = (int32_t)(tile_size_bytes / - sizeof(typename index_type::feature_type) / - this->get_dimensions()); + tile_size = compute_tile_size(); default_compression = string_to_filter( storage_formats[this->version_]["default_attr_filters"]); }