Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two improvements for the IndexBuilding #472

Merged
merged 3 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/index/ExternalVocabulary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "../parser/RdfEscaping.h"
#include "../parser/Tokenizer.h"
#include "../util/BufferedVector.h"
#include "../util/Log.h"

// _____________________________________________________________________________
Expand Down Expand Up @@ -71,7 +72,8 @@ void ExternalVocabulary<Comp>::buildFromTextFile(const string& textFileName,
_file.open(outFileName.c_str(), "w");
std::ifstream infile(textFileName);
AD_CHECK(infile.is_open());
vector<off_t> offsets;
ad_utility::BufferedVector<off_t> offsets(
1'000'000'000, textFileName + ".offset.tmp.buffer");
off_t currentOffset = 0;
_size = 0;
std::string word;
Expand Down
1 change: 1 addition & 0 deletions src/index/Index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ VocabularyData Index::passFileForVocabulary(const string& filename,
LOG(INFO) << "Merging temporary vocabulary for prefix compression";
{
VocabularyMerger m;
m._ignoreExternalVocabulary = true;
m.mergeVocabulary(_onDiskBase + TMP_BASENAME_COMPRESSION, numFiles,
std::less<>());
LOG(INFO) << "Finished merging additional Vocabulary.";
Expand Down
1 change: 1 addition & 0 deletions src/index/VocabularyGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using TripleVec = stxxl::vector<array<Id, 3>>;
*/
class VocabularyMerger {
public:
bool _ignoreExternalVocabulary = false;
// result of a call to mergeVocabulary
struct VocMergeRes {
size_t _numWordsTotal; // that many distinct words were found (size of the
Expand Down
7 changes: 7 additions & 0 deletions src/index/VocabularyGeneratorImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ VocabularyMerger::VocMergeRes VocabularyMerger::mergeVocabulary(

// start k-way merge
while (!queue.empty()) {
// for the prefix compression vocabulary, we don't need the external
// vocabulary
if (_ignoreExternalVocabulary &&
queue.top()._value >= EXTERNALIZED_LITERALS_PREFIX) {
break;
}

// accumulated the globally ordered queue words in a buffer.
sortedBuffer.push_back(std::move(queue.top()));
queue.pop();
Expand Down