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

Don't crash on empty index. Fixes #262 #263

Merged
merged 1 commit into from
Jul 11, 2019
Merged
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
12 changes: 8 additions & 4 deletions src/index/Index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,17 +561,21 @@ void Index::createPatternsImpl(const string& fileName,
typedef std::unordered_map<Pattern, size_t> PatternsCountMap;

LOG(INFO) << "Creating patterns file..." << std::endl;
PatternsCountMap patternCounts;
VecReaderType reader(vecReaderArgs...);
if (reader.empty()) {
LOG(WARN) << "Triple vector was empty, no patterns created" << std::endl;
return;
}

PatternsCountMap patternCounts;
// determine the most common patterns
Pattern pattern;

size_t patternIndex = 0;
Id currentSubj;
currentSubj = (*VecReaderType(vecReaderArgs...))[0];
size_t numValidPatterns = 0;
Id currentSubj = (*reader)[0];

for (VecReaderType reader(vecReaderArgs...); !reader.empty(); ++reader) {
for (; !reader.empty(); ++reader) {
auto triple = *reader;
if (triple[0] != currentSubj) {
currentSubj = triple[0];
Expand Down