From 29debc894173443e2fced709dd6c3c2e84fde5c1 Mon Sep 17 00:00:00 2001 From: morningman Date: Sun, 25 Oct 2026 15:48:11 +0800 Subject: [PATCH] [fix](be) Pass uint64_t offsets to the ANN index writer in unit tests ### What problem does this PR solve? Issue Number: None Related PR: #69070 Problem Summary: #69070 changed the offsets parameter of the ANN index writers' add_array_values() to const uint64_t*, but three unit tests still build their offsets as std::vector and pass offsets.data(): ann_index_writer_test.cpp (15 places), ann_index_edge_case_test.cpp and snii_ann_container_test.cpp. On Linux size_t and uint64_t are both unsigned long, so the tests compile. On macOS size_t is unsigned long and uint64_t is unsigned long long, and ann_index_edge_case_test.cpp fails with "cannot initialize a parameter of type 'const uint64_t *' (aka 'const unsigned long long *') with an rvalue of type 'value_type *' (aka 'unsigned long *')". The vector_search_test library is force-loaded into doris_be_test, so no BE unit test builds on macOS. The macOS CI pipeline builds the BE without tests and does not see it. These tests now declare the offsets as std::vector, the type the writer takes. Production code is unchanged. ### Release note None ### Check List (For Author) - Test: Unit Test - macOS: the BE UT build compiles the three files and links doris_be_test again; AnnIndexWriterTest, VectorSearchTest and SniiAnnContainerTest pass. - Behavior changed: No - Does this need documentation: No Co-Authored-By: Claude Opus 5.5 (1M context) --- .../index/ann/ann_index_edge_case_test.cpp | 2 +- .../index/ann/ann_index_writer_test.cpp | 30 +++++++++---------- .../inverted/snii/snii_ann_container_test.cpp | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/be/test/storage/index/ann/ann_index_edge_case_test.cpp b/be/test/storage/index/ann/ann_index_edge_case_test.cpp index 007a61ec511174..9b6c0241d6813c 100644 --- a/be/test/storage/index/ann/ann_index_edge_case_test.cpp +++ b/be/test/storage/index/ann/ann_index_edge_case_test.cpp @@ -267,7 +267,7 @@ TEST_F(VectorSearchTest, TestLargeVectorDimensions) { vectors[i] = static_cast(i % 100) / 100.0f; } - std::vector offsets = {0, dim, 2 * dim}; + std::vector offsets = {0, dim, 2 * dim}; Status status = writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), diff --git a/be/test/storage/index/ann/ann_index_writer_test.cpp b/be/test/storage/index/ann/ann_index_writer_test.cpp index 57dfef884e16ed..aaa04740b631d5 100644 --- a/be/test/storage/index/ann/ann_index_writer_test.cpp +++ b/be/test/storage/index/ann/ann_index_writer_test.cpp @@ -207,7 +207,7 @@ TEST_F(AnnIndexWriterTest, TestAddArrayValuesSuccess) { 9.0f, 10.0f, 11.0f, 12.0f // Row 2 }; - std::vector offsets = {0, 4, 8, 12}; // Each row has 4 elements + std::vector offsets = {0, 4, 8, 12}; // Each row has 4 elements Status status = writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), @@ -310,7 +310,7 @@ TEST_F(AnnIndexWriterTest, TestAddArrayValuesWrongDimension) { 4.0f, 5.0f, 6.0f // Row 1: 3 elements (wrong) }; - std::vector offsets = {0, 3, 6}; // Each row has 3 elements instead of 4 + std::vector offsets = {0, 3, 6}; // Each row has 3 elements instead of 4 Status status = writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), @@ -405,7 +405,7 @@ TEST_F(AnnIndexWriterTest, TestFinish) { 5.0f, 6.0f, 7.0f, 8.0f // Row 1 }; - std::vector offsets = {0, 4, 8}; + std::vector offsets = {0, 4, 8}; ASSERT_TRUE(writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), nullptr, @@ -436,7 +436,7 @@ TEST_F(AnnIndexWriterTest, TestFullWorkflow) { { const size_t num_rows = 2; std::vector vectors = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f}; - std::vector offsets = {0, 4, 8}; + std::vector offsets = {0, 4, 8}; ASSERT_TRUE(writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), @@ -449,7 +449,7 @@ TEST_F(AnnIndexWriterTest, TestFullWorkflow) { const size_t num_rows = 3; std::vector vectors = {9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f}; - std::vector offsets = {0, 4, 8, 12}; + std::vector offsets = {0, 4, 8, 12}; ASSERT_TRUE(writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), @@ -525,7 +525,7 @@ TEST_F(AnnIndexWriterTest, TestNoTrainIndexAddsAtFinish) { for (size_t i = 0; i < vectors.size(); ++i) { vectors[i] = static_cast(batch * vectors.size() + i); } - std::vector offsets; + std::vector offsets; for (size_t row = 0; row <= batch_rows; ++row) { offsets.push_back(row * dim); } @@ -582,7 +582,7 @@ TEST_F(AnnIndexWriterTest, TestNoTrainIndexSkipsWhenRowsLessThanMinSegmentRows) for (size_t i = 0; i < vectors.size(); ++i) { vectors[i] = static_cast(i); } - std::vector offsets; + std::vector offsets; for (size_t row = 0; row <= num_rows; ++row) { offsets.push_back(row * dim); } @@ -626,7 +626,7 @@ TEST_F(AnnIndexWriterTest, TestTrainRequiredIndexUsesEffectiveMinSegmentRows) { for (size_t i = 0; i < vectors.size(); ++i) { vectors[i] = static_cast(i); } - std::vector offsets; + std::vector offsets; for (size_t row = 0; row <= num_rows; ++row) { offsets.push_back(row * dim); } @@ -684,7 +684,7 @@ TEST_F(AnnIndexWriterTest, TestCreateFromIndexColumnWriter) { 9.0f, 10.0f, 11.0f, 12.0f // Row 2 }; - std::vector offsets = {0, 4, 8, 12}; // Each row has 4 elements + std::vector offsets = {0, 4, 8, 12}; // Each row has 4 elements status = column_writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), @@ -722,7 +722,7 @@ TEST_F(AnnIndexWriterTest, TestAddArrayValuesIVF) { 9.0f, 10.0f, 11.0f, 12.0f // Row 2 }; - std::vector offsets = {0, 4, 8, 12}; // Each row has 4 elements + std::vector offsets = {0, 4, 8, 12}; // Each row has 4 elements Status status = writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), @@ -762,7 +762,7 @@ TEST_F(AnnIndexWriterTest, TestSmallTrainRequiredIndexUsesMemoryBuffer) { for (size_t i = 0; i < vectors.size(); ++i) { vectors[i] = static_cast(i); } - std::vector offsets; + std::vector offsets; for (size_t row = 0; row <= num_rows; ++row) { offsets.push_back(row * dim); } @@ -829,7 +829,7 @@ TEST_F(AnnIndexWriterTest, TestTrainRequiredIndexTrainsOnceAndAddsAllRows) { 17.0f, 18.0f, 19.0f, 20.0f, // Row 4 21.0f, 22.0f, 23.0f, 24.0f // Row 5 }; - std::vector offsets = {0, 4, 8, 12, 16, 20, 24}; + std::vector offsets = {0, 4, 8, 12, 16, 20, 24}; Status status = writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), @@ -847,7 +847,7 @@ TEST_F(AnnIndexWriterTest, TestTrainRequiredIndexTrainsOnceAndAddsAllRows) { 41.0f, 42.0f, 43.0f, 44.0f, // Row 10 45.0f, 46.0f, 47.0f, 48.0f // Row 11 }; - std::vector offsets = {0, 4, 8, 12, 16, 20, 24}; + std::vector offsets = {0, 4, 8, 12, 16, 20, 24}; Status status = writer->add_array_values(sizeof(float), reinterpret_cast(vectors.data()), @@ -899,7 +899,7 @@ TEST_F(AnnIndexWriterTest, TestTrainRequiredIndexTrainsWithAllBufferedRows) { vectors[row * dim + col] = static_cast(row); } } - std::vector offsets; + std::vector offsets; for (size_t row = 0; row <= num_rows; ++row) { offsets.push_back(row * dim); } @@ -957,7 +957,7 @@ TEST_F(AnnIndexWriterTest, TestSkipIndexWhenTotalRowsLessThanMinTrainRows) { for (size_t i = 0; i < vectors.size(); ++i) { vectors[i] = static_cast(i); } - std::vector offsets; + std::vector offsets; for (size_t row = 0; row <= num_rows; ++row) { offsets.push_back(row * dim); } diff --git a/be/test/storage/index/inverted/snii/snii_ann_container_test.cpp b/be/test/storage/index/inverted/snii/snii_ann_container_test.cpp index 59c9de32f877bd..3970066484206f 100644 --- a/be/test/storage/index/inverted/snii/snii_ann_container_test.cpp +++ b/be/test/storage/index/inverted/snii/snii_ann_container_test.cpp @@ -229,7 +229,7 @@ class SniiAnnContainerTest : public testing::Test { // finish_ann_index() below cannot express. static Status feed_and_finish(AnnIndexColumnWriter* ann) { const std::vector vectors = make_vectors(); - std::vector offsets(kRows + 1); + std::vector offsets(kRows + 1); for (uint32_t i = 0; i <= kRows; ++i) { offsets[i] = static_cast(i) * kDim; }