This is an automated email from the ASF dual-hosted git repository.
csun5285 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 7679a4f2d6d [fix](be) Pass uint64_t offsets to the ANN index writer in
unit tests (#69584)
7679a4f2d6d is described below
commit 7679a4f2d6dc634faf27dd24887a8790e16002ce
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Sun Oct 25 15:50:45 2026 +0000
[fix](be) Pass uint64_t offsets to the ANN index writer in unit tests
(#69584)
**In short.** Since #69070, the BE unit tests no longer compile on
macOS: three ANN tests pass `std::vector<size_t>::data()` where the
writer now takes `const uint64_t*`. The tests now use
`std::vector<uint64_t>`.
**Background.** #69070 changed the offsets parameter of the ANN index
writers' `add_array_values()` from `const uint8_t*` to `const
uint64_t*`. The `vector_search_test` library, which holds the ANN tests,
is force-loaded into `doris_be_test`.
**The problem, and what it cost.** `ann_index_writer_test.cpp` (15
places), `ann_index_edge_case_test.cpp` and
`snii_ann_container_test.cpp` still build their offsets as
`std::vector<size_t>`. On Linux `size_t` and `uint64_t` are both
`unsigned long`, so they compile. On macOS `size_t` is `unsigned long`
and `uint64_t` is `unsigned long long`, and the build stops at:
```
ann_index_edge_case_test.cpp:274:55: error: cannot initialize a parameter
of type 'const uint64_t *' (aka 'const unsigned long long *') with an rvalue of
type 'value_type *' (aka 'unsigned long *')
```
Because `vector_search_test` is linked into `doris_be_test`, no BE unit
test can be built on macOS. The macOS CI pipeline builds the BE without
tests, so CI does not report it.
**How this PR fixes it.** The 17 offsets vectors in those tests are
declared as `std::vector<uint64_t>`, the type the writer takes.
Production code is unchanged.
---
.../storage/index/ann/ann_index_edge_case_test.cpp | 2 +-
.../storage/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 007a61ec511..9b6c0241d68 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<float>(i % 100) / 100.0f;
}
- std::vector<size_t> offsets = {0, dim, 2 * dim};
+ std::vector<uint64_t> offsets = {0, dim, 2 * dim};
Status status = writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(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 57dfef884e1..aaa04740b63 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<size_t> offsets = {0, 4, 8, 12}; // Each row has 4 elements
+ std::vector<uint64_t> offsets = {0, 4, 8, 12}; // Each row has 4 elements
Status status = writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(vectors.data()),
@@ -310,7 +310,7 @@ TEST_F(AnnIndexWriterTest,
TestAddArrayValuesWrongDimension) {
4.0f, 5.0f, 6.0f // Row 1: 3 elements (wrong)
};
- std::vector<size_t> offsets = {0, 3, 6}; // Each row has 3 elements
instead of 4
+ std::vector<uint64_t> offsets = {0, 3, 6}; // Each row has 3 elements
instead of 4
Status status = writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(vectors.data()),
@@ -405,7 +405,7 @@ TEST_F(AnnIndexWriterTest, TestFinish) {
5.0f, 6.0f, 7.0f, 8.0f // Row 1
};
- std::vector<size_t> offsets = {0, 4, 8};
+ std::vector<uint64_t> offsets = {0, 4, 8};
ASSERT_TRUE(writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(vectors.data()), nullptr,
@@ -436,7 +436,7 @@ TEST_F(AnnIndexWriterTest, TestFullWorkflow) {
{
const size_t num_rows = 2;
std::vector<float> vectors = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f,
7.0f, 8.0f};
- std::vector<size_t> offsets = {0, 4, 8};
+ std::vector<uint64_t> offsets = {0, 4, 8};
ASSERT_TRUE(writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(vectors.data()),
@@ -449,7 +449,7 @@ TEST_F(AnnIndexWriterTest, TestFullWorkflow) {
const size_t num_rows = 3;
std::vector<float> 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<size_t> offsets = {0, 4, 8, 12};
+ std::vector<uint64_t> offsets = {0, 4, 8, 12};
ASSERT_TRUE(writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(vectors.data()),
@@ -525,7 +525,7 @@ TEST_F(AnnIndexWriterTest, TestNoTrainIndexAddsAtFinish) {
for (size_t i = 0; i < vectors.size(); ++i) {
vectors[i] = static_cast<float>(batch * vectors.size() + i);
}
- std::vector<size_t> offsets;
+ std::vector<uint64_t> 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<float>(i);
}
- std::vector<size_t> offsets;
+ std::vector<uint64_t> 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<float>(i);
}
- std::vector<size_t> offsets;
+ std::vector<uint64_t> 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<size_t> offsets = {0, 4, 8, 12}; // Each row has 4 elements
+ std::vector<uint64_t> offsets = {0, 4, 8, 12}; // Each row has 4 elements
status = column_writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(vectors.data()),
@@ -722,7 +722,7 @@ TEST_F(AnnIndexWriterTest, TestAddArrayValuesIVF) {
9.0f, 10.0f, 11.0f, 12.0f // Row 2
};
- std::vector<size_t> offsets = {0, 4, 8, 12}; // Each row has 4 elements
+ std::vector<uint64_t> offsets = {0, 4, 8, 12}; // Each row has 4 elements
Status status = writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(vectors.data()),
@@ -762,7 +762,7 @@ TEST_F(AnnIndexWriterTest,
TestSmallTrainRequiredIndexUsesMemoryBuffer) {
for (size_t i = 0; i < vectors.size(); ++i) {
vectors[i] = static_cast<float>(i);
}
- std::vector<size_t> offsets;
+ std::vector<uint64_t> 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<size_t> offsets = {0, 4, 8, 12, 16, 20, 24};
+ std::vector<uint64_t> offsets = {0, 4, 8, 12, 16, 20, 24};
Status status = writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(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<size_t> offsets = {0, 4, 8, 12, 16, 20, 24};
+ std::vector<uint64_t> offsets = {0, 4, 8, 12, 16, 20, 24};
Status status = writer->add_array_values(sizeof(float),
reinterpret_cast<const
uint8_t*>(vectors.data()),
@@ -899,7 +899,7 @@ TEST_F(AnnIndexWriterTest,
TestTrainRequiredIndexTrainsWithAllBufferedRows) {
vectors[row * dim + col] = static_cast<float>(row);
}
}
- std::vector<size_t> offsets;
+ std::vector<uint64_t> 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<float>(i);
}
- std::vector<size_t> offsets;
+ std::vector<uint64_t> 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 59c9de32f87..39700664842 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 @@ protected:
// finish_ann_index() below cannot express.
static Status feed_and_finish(AnnIndexColumnWriter* ann) {
const std::vector<float> vectors = make_vectors();
- std::vector<size_t> offsets(kRows + 1);
+ std::vector<uint64_t> offsets(kRows + 1);
for (uint32_t i = 0; i <= kRows; ++i) {
offsets[i] = static_cast<size_t>(i) * kDim;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]