Skip to content

Commit

Permalink
A lot of stuff not working with the external vocabulary...
Browse files Browse the repository at this point in the history
We really have to fix this...
  • Loading branch information
joka921 committed Jul 10, 2024
1 parent 4329a4c commit aa2bfad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
23 changes: 14 additions & 9 deletions src/index/PatternCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@ static const Id hasPatternId = qlever::specialIds.at(HAS_PATTERN_PREDICATE);
// _________________________________________________________________________
void PatternCreator::processTriple(std::array<Id, 3> triple,
bool ignoreForPatterns) {
if (ignoreForPatterns) {
tripleBuffer_.emplace_back(triple, ignoreForPatterns);
return;
}
if (!currentSubject_.has_value()) {
// This is the first triple.
currentSubject_ = triple[0];
currentSubjectCompletelyIgnored_ = ignoreForPatterns;
} else if (triple[0] != currentSubject_) {
// New subject.
finishSubject(currentSubject_.value(), currentPattern_);
currentSubject_ = triple[0];
currentPattern_.clear();
currentSubjectCompletelyIgnored_ = true;
}
tripleBuffer_.emplace_back(triple, ignoreForPatterns);
if (ignoreForPatterns) {
return;
}
currentSubjectCompletelyIgnored_ = false;
// Don't list predicates twice in the same pattern.
if (currentPattern_.empty() || currentPattern_.back() != triple[1]) {
currentPattern_.push_back(triple[1]);
Expand Down Expand Up @@ -54,17 +56,20 @@ void PatternCreator::finishSubject(Id subject, const Pattern& pattern) {
it->second.count_++;
}

auto additionalTriple =
std::array{subject, hasPatternId, Id::makeFromInt(patternId)};
tripleSorter_.hasPatternPredicateSortedByPSO_->push(additionalTriple);
if (!currentSubjectCompletelyIgnored_) {
auto additionalTriple =
std::array{subject, hasPatternId, Id::makeFromInt(patternId)};
tripleSorter_.hasPatternPredicateSortedByPSO_->push(additionalTriple);
}
auto curSubject = currentSubject_.value();
std::ranges::for_each(tripleBuffer_, [this, patternId,
&curSubject](const auto& t) {
const auto& [s, p, o] = t.triple_;
AD_CORRECTNESS_CHECK(s == curSubject);
// It might happen that the `tripleBuffer_` contains different subjects
// which are purely internal and therefore have no pattern.
auto actualPatternId =
Id::makeFromInt(curSubject != s ? NO_PATTERN : patternId);
auto actualPatternId = Id::makeFromInt(
currentSubjectCompletelyIgnored_ ? NO_PATTERN : patternId);
AD_CORRECTNESS_CHECK(curSubject == s || t.isInternal_);
ospSorterTriplesWithPattern().push(std::array{s, p, o, actualPatternId});
});
Expand Down
1 change: 1 addition & 0 deletions src/index/PatternCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class PatternCreator {
// subject (the subject of the last triple for which `processTriple` was
// called).
std::optional<Id> currentSubject_;
bool currentSubjectCompletelyIgnored_ = true;
// The pattern of `currentSubject_`. This might still be incomplete,
// because more triples with the same subject might be pushed.
Pattern currentPattern_;
Expand Down
2 changes: 1 addition & 1 deletion test/util/IndexTestHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Index makeTestIndex(const std::string& indexBasename,
"<x> <label> \"alpha\" . <x> <label> \"älpha\" . <x> <label> \"A\" . "
"<x> "
"<label> \"Beta\". <x> <is-a> <y>. <y> <is-a> <x>. <z> <label> "
"\"zz\"@en";
"\"zz\"@en . <zz> <label> <zz>";
}

FILE_BUFFER_SIZE = 1000;
Expand Down

0 comments on commit aa2bfad

Please sign in to comment.