fix: review fixed

This commit is contained in:
Volodymyr Yavdoshenko 2025-04-23 18:50:55 +03:00
parent 0ba68b9cae
commit 2f2fc92a0d
No known key found for this signature in database
GPG key ID: 24BC74845F4F4064
3 changed files with 11 additions and 12 deletions

View file

@ -281,7 +281,10 @@ struct HnswlibAdapter {
}
void Remove(DocId id) {
world_.markDelete(id);
try {
world_.markDelete(id);
} catch (const std::exception& e) {
}
}
vector<pair<float, DocId>> Knn(float* target, size_t k, std::optional<size_t> ef) {

View file

@ -322,14 +322,10 @@ void ShardDocIndex::RemoveDoc(string_view key, const DbContext& db_cntx, const P
if (!indices_)
return;
try {
auto accessor = GetAccessor(db_cntx, pv);
auto id = key_index_.Remove(key);
if (id) {
indices_->Remove(id.value(), *accessor);
}
} catch (const std::exception& e) {
LOG(WARNING) << "Exception while removing document " << key << ": " << e.what();
auto accessor = GetAccessor(db_cntx, pv);
auto id = key_index_.Remove(key);
if (id) {
indices_->Remove(id.value(), *accessor);
}
}

View file

@ -2722,7 +2722,7 @@ TEST_F(SearchFamilyTest, JsonWithNullFields) {
AreDocIds("doc:1", "doc:2"));
}
TEST_F(SearchFamilyTest, TestTwoHsetDocumentCreationCrashes) {
TEST_F(SearchFamilyTest, TestHsetDeleteDocumentHnswSchemaCrash) {
EXPECT_EQ(Run({"FT.CREATE", "idx", "SCHEMA", "n", "NUMERIC", "v", "VECTOR", "HNSW", "8", "TYPE",
"FLOAT16", "DIM", "4", "DISTANCE_METRIC", "L2", "M", "65536"}),
"OK");
@ -2730,8 +2730,8 @@ TEST_F(SearchFamilyTest, TestTwoHsetDocumentCreationCrashes) {
auto res = Run({"HSET", "doc", "n", "0"});
EXPECT_EQ(res, 1);
res = Run({"HSET", "doc", "n", "1"});
EXPECT_EQ(res, 0);
res = Run({"DEL", "doc"});
EXPECT_EQ(res, 1);
}
} // namespace dfly