logic: fixed missing matches in fulltext search

This commit is contained in:
mlangkabel
2018-04-24 19:18:26 +02:00
parent bac9f7fbc4
commit d29cabd0b3
4 changed files with 27 additions and 17 deletions
@@ -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>();
+2 -2
View File
@@ -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]);
}
+1 -1
View File
@@ -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;
+23 -13
View File
@@ -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)
{