Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions fts/src/function/query_fts_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ using VCQueryTerm = std::variant<std::string, std::unique_ptr<RE2>>;
class MatchTermsVertexCompute final : public VertexCompute {
public:
explicit MatchTermsVertexCompute(std::unordered_map<offset_t, uint64_t>& resDfs,
std::vector<VCQueryTerm>& queryTerms)
: resDfs{resDfs}, queryTerms{queryTerms} {}
std::vector<VCQueryTerm>& queryTerms,
std::shared_ptr<std::mutex> resDfsMutex = std::make_shared<std::mutex>())
: resDfs{resDfs}, queryTerms{queryTerms}, resDfsMutex{std::move(resDfsMutex)} {}
void vertexCompute(const graph::VertexScanState::Chunk& chunk) override {
auto terms = chunk.getProperties<string_t>(0);
auto dfs = chunk.getProperties<uint64_t>(1);
Expand All @@ -259,26 +260,29 @@ 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];
}
}
} else {
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];
}
}
}
}
}
std::unique_ptr<VertexCompute> copy() override {
return std::make_unique<MatchTermsVertexCompute>(resDfs, queryTerms);
return std::make_unique<MatchTermsVertexCompute>(resDfs, queryTerms, resDfsMutex);
}

private:
std::unordered_map<offset_t, uint64_t>& resDfs;
std::vector<VCQueryTerm>& queryTerms;
std::shared_ptr<std::mutex> resDfsMutex;
};

static constexpr char SCORE_PROP_NAME[] = "score";
Expand Down