logic: fixed missing matches in fulltext search
This commit is contained in:
@@ -1651,7 +1651,7 @@ void GraphController::groupTrailNodes(GroupType groupType)
|
||||
groupNode->groupLayout = GroupLayout::SKEWED;
|
||||
|
||||
// Use token Id of first node and make first 2 bits 1
|
||||
groupNode->tokenId = ~(~size_t(0) >> 2) + node.nodeId;
|
||||
groupNode->tokenId = ~(~Id(0) >> 2) + node.nodeId;
|
||||
m_topLevelAncestorIds[groupNode->tokenId] = groupNode->tokenId;
|
||||
|
||||
std::shared_ptr<DummyEdge> targetEdge = std::make_shared<DummyEdge>();
|
||||
|
||||
@@ -9,7 +9,7 @@ struct suffix
|
||||
int rank[2];
|
||||
};
|
||||
|
||||
int SuffixArray::cmp(struct suffix a, struct suffix b)
|
||||
int SuffixArray::cmp(const struct suffix& a, const struct suffix& b)
|
||||
{
|
||||
return (a.rank[0] == b.rank[0]) ? (a.rank[1] < b.rank[1] ? 1 : 0) : (a.rank[0] < b.rank[0] ? 1 : 0);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ std::vector<int> SuffixArray::searchForTerm(const std::wstring& searchTerm) cons
|
||||
{
|
||||
matches.push_back(m_array[lower]);
|
||||
}
|
||||
for (int higher = m+1; higher < termLength && m_lcp[higher-1] >= termLength; higher++)
|
||||
for (int higher = m+1; higher < m_text.length() && m_lcp[higher-1] >= termLength; higher++)
|
||||
{
|
||||
matches.push_back(m_array[higher]);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class SuffixArray
|
||||
public:
|
||||
SuffixArray(const std::wstring& text);
|
||||
std::vector<int> searchForTerm(const std::wstring& searchTerm) const;
|
||||
static int cmp(struct suffix a, struct suffix b);
|
||||
static int cmp(const struct suffix& a, const struct suffix& b);
|
||||
|
||||
void printArray() const;
|
||||
void printLCP() const;
|
||||
|
||||
@@ -2787,22 +2787,32 @@ void PersistentStorage::buildFullTextSearchIndex() const
|
||||
m_fullTextSearchIndex.clear();
|
||||
|
||||
std::vector<std::shared_ptr<std::thread>> threads;
|
||||
for (std::vector<StorageFile> part : utility::splitToEqualySizedParts(m_sqliteIndexStorage.getAll<StorageFile>(), utility::getIdealThreadCount()))
|
||||
{
|
||||
std::shared_ptr<std::thread> thread = std::make_shared<std::thread>(
|
||||
[&](const std::vector<StorageFile>& files)
|
||||
std::vector<StorageFile> indexedFiles;
|
||||
for (const StorageFile& file : m_sqliteIndexStorage.getAll<StorageFile>())
|
||||
{
|
||||
if (file.indexed)
|
||||
{
|
||||
for (const StorageFile& file : files)
|
||||
indexedFiles.push_back(file);
|
||||
}
|
||||
}
|
||||
for (std::vector<StorageFile> part : utility::splitToEqualySizedParts(indexedFiles, utility::getIdealThreadCount()))
|
||||
{
|
||||
std::shared_ptr<std::thread> thread = std::make_shared<std::thread>(
|
||||
[&](const std::vector<StorageFile>& files)
|
||||
{
|
||||
m_fullTextSearchIndex.addFile(
|
||||
file.id,
|
||||
codec.decode(m_sqliteIndexStorage.getFileContentById(file.id)->getText())
|
||||
);
|
||||
}
|
||||
},
|
||||
part
|
||||
);
|
||||
threads.push_back(thread);
|
||||
for (const StorageFile& file : files)
|
||||
{
|
||||
m_fullTextSearchIndex.addFile(
|
||||
file.id,
|
||||
codec.decode(m_sqliteIndexStorage.getFileContentById(file.id)->getText())
|
||||
);
|
||||
}
|
||||
},
|
||||
part
|
||||
);
|
||||
threads.push_back(thread);
|
||||
}
|
||||
}
|
||||
for (std::shared_ptr<std::thread> thread : threads)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user