From e06f02a1ccbcbf832dd8ee1222c32b10358e7fca Mon Sep 17 00:00:00 2001 From: future3000 Date: Tue, 21 Apr 2026 20:57:33 +1200 Subject: [PATCH] fix(fts): synchronize wildcard df accumulation --- fts/src/function/query_fts_index.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fts/src/function/query_fts_index.cpp b/fts/src/function/query_fts_index.cpp index 5e4212e..999ff8f 100644 --- a/fts/src/function/query_fts_index.cpp +++ b/fts/src/function/query_fts_index.cpp @@ -247,8 +247,9 @@ using VCQueryTerm = std::variant>; class MatchTermsVertexCompute final : public VertexCompute { public: explicit MatchTermsVertexCompute(std::unordered_map& resDfs, - std::vector& queryTerms) - : resDfs{resDfs}, queryTerms{queryTerms} {} + std::vector& queryTerms, + std::shared_ptr resDfsMutex = std::make_shared()) + : resDfs{resDfs}, queryTerms{queryTerms}, resDfsMutex{std::move(resDfsMutex)} {} void vertexCompute(const graph::VertexScanState::Chunk& chunk) override { auto terms = chunk.getProperties(0); auto dfs = chunk.getProperties(1); @@ -259,6 +260,7 @@ class MatchTermsVertexCompute final : public VertexCompute { std::string& queryString = std::get<0>(queryTerm); for (auto i = 0u; i < chunk.size(); ++i) { if (queryString == terms[i].getAsString()) { + std::lock_guard guard{*resDfsMutex}; resDfs[nodeIds[i].offset] = dfs[i]; } } @@ -266,6 +268,7 @@ class MatchTermsVertexCompute final : public VertexCompute { RE2& regex = *std::get<1>(queryTerm); for (auto i = 0u; i < chunk.size(); ++i) { if (RE2::FullMatch(terms[i].getAsString(), regex)) { + std::lock_guard guard{*resDfsMutex}; resDfs[nodeIds[i].offset] = dfs[i]; } } @@ -273,12 +276,13 @@ class MatchTermsVertexCompute final : public VertexCompute { } } std::unique_ptr copy() override { - return std::make_unique(resDfs, queryTerms); + return std::make_unique(resDfs, queryTerms, resDfsMutex); } private: std::unordered_map& resDfs; std::vector& queryTerms; + std::shared_ptr resDfsMutex; }; static constexpr char SCORE_PROP_NAME[] = "score";