diff options
Diffstat (limited to 'searchlib/src/tests/attribute')
-rw-r--r-- | searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index bf0b74b0003..72b2f1e320a 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -157,6 +157,12 @@ public: void expect_empty_add() const { EXPECT_TRUE(_adds.empty()); } + void expect_empty_prepare_add() const { + EXPECT_TRUE(_prepare_adds.empty()); + } + void expect_empty_complete_add() const { + EXPECT_TRUE(_complete_adds.empty()); + } void expect_entry(uint32_t exp_docid, const DoubleVector& exp_vector, const EntryVector& entries) const { EXPECT_EQUAL(1u, entries.size()); EXPECT_EQUAL(exp_docid, entries.back().first); @@ -881,6 +887,30 @@ TEST_F("nearest neighbor index can be updated in two phases", DenseTensorAttribu } } +TEST_F("nearest neighbor index is NOT updated when tensor value is unchanged", DenseTensorAttributeMockIndex) +{ + auto& index = f.mock_index(); + { + auto vec_a = vec_2d(3, 5); + auto prepare_result = f.prepare_set_tensor(1, vec_a); + index.expect_prepare_add(1, {3, 5}); + f.complete_set_tensor(1, vec_a, std::move(prepare_result)); + f.assertGetTensor(vec_a, 1); + index.expect_complete_add(1, {3, 5}); + } + index.clear(); + { + // Replaces previous value with the same value + auto vec_b = vec_2d(3, 5); + auto prepare_result = f.prepare_set_tensor(1, vec_b); + EXPECT_TRUE(prepare_result.get() == nullptr); + index.expect_empty_prepare_add(); + f.complete_set_tensor(1, vec_b, std::move(prepare_result)); + f.assertGetTensor(vec_b, 1); + index.expect_empty_complete_add(); + } +} + TEST_F("clearDoc() updates nearest neighbor index", DenseTensorAttributeMockIndex) { auto& index = f.mock_index(); |