Skip to content

Conversation

@RobinTF
Copy link
Collaborator

@RobinTF RobinTF commented Oct 23, 2025

This PR extends the DeltaTriples class to also store changes for internal triples. It also implements a hook that adds internal triples for every object literal with language literals so that these internal triples are filled when required. This does not include the ql:langtag triples, these need a little bit more consideration.

Currently WIP, unit tests are missing and some code might not be ideal yet.

@RobinTF RobinTF requested review from Qup42 and joka921 October 23, 2025 15:49
@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 95.58824% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.20%. Comparing base (50d08bc) to head (55dc98e).

Files with missing lines Patch % Lines
src/index/DeltaTriples.cpp 95.74% 0 Missing and 4 partials ⚠️
src/engine/ExportQueryExecutionTrees.cpp 88.88% 0 Missing and 1 partial ⚠️
src/index/Permutation.h 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2461      +/-   ##
==========================================
- Coverage   91.20%   91.20%   -0.01%     
==========================================
  Files         473      473              
  Lines       40233    40312      +79     
  Branches     5378     5387       +9     
==========================================
+ Hits        36695    36765      +70     
- Misses       2006     2007       +1     
- Partials     1532     1540       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@joka921 joka921 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A first round of 1-1 reviews.

Comment on lines 135 to 136
auto predicate = ExportQueryExecutionTrees::idToLiteralOrIri(
index_, predicateId, localVocab_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best do some deduplication, don't look up the same predicate n times...

Copy link
Member

@Qup42 Qup42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question and a change from me for the review.

My understanding is that for triples where the object has a language tag the internal permutations stores the that triple with the predicate also having the language tag. So simplified for <foo> <bar> "baz"@en" something like <foo> <bar>@en@ "baz" is stored. Is this used for anything else than FILTER(LANG(?x) = "...")?

LocatedTriples::iterator&
DeltaTriples::LocatedTripleHandles<internal>::forPermutation(
Permutation::Enum permutation) {
return handles_[static_cast<size_t>(permutation)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this assumes that the internal permutations PSO and POS are first and second in the enum for the index into the array to work out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member

@Qup42 Qup42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Once the timing statements are added we can investigate the performance impact of the changes.

Comment on lines +418 to +419
ql::ranges::for_each(internalLocatedTriples_,
&LocatedTriplesPerBlock::updateAugmentedMetadata);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably more a note to myself. To reduce the performance impact it would be nice to have a way to only update the metadata of the internal permutation if they have actually been changed. How important this is also depends on how large the internal permutations are compared to the external permutations.

Comment on lines +120 to +121
auto optionalLiteralOrIri = ExportQueryExecutionTrees::idToLiteralOrIri(
index_, objectId, localVocab_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Some thinking aloud) We start with TripleComponents from the parser, lookup their IDs and now resolve the IDs back to the literal Values. That is a bit strange. But I also don't see an obvious place to do this where everything is present in TripleComponents. Variables are only bound to the value from the result once everything has been translated to IDs.

AD_CORRECTNESS_CHECK(predicate.has_value() && predicate.value().isIri());
auto specialPredicate = ad_utility::convertToLanguageTaggedPredicate(
predicate.value().getIri(),
std::string{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make this parameter of ad_utility::convertToLanguageTaggedPredicate a std::string_view?

void DeltaTriples::insertTriples(CancellationHandle cancellationHandle,
Triples triples,
ad_utility::timer::TimeTracer& tracer) {
auto internalTriples = makeInternalTriples(triples);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto internalTriples = makeInternalTriples(triples);
tracer.beginTrace("makeInternalTriples");
auto internalTriples = makeInternalTriples(triples);
tracer.endTrace("makeInternalTriples");

Comment on lines 151 to 155
modifyTriplesImpl(cancellationHandle, std::move(triples), true,
triplesInserted_, triplesDeleted_, tracer);
modifyTriplesImpl(std::move(cancellationHandle), std::move(internalTriples),
true, internalTriplesInserted_, internalTriplesDeleted_,
tracer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
modifyTriplesImpl(cancellationHandle, std::move(triples), true,
triplesInserted_, triplesDeleted_, tracer);
modifyTriplesImpl(std::move(cancellationHandle), std::move(internalTriples),
true, internalTriplesInserted_, internalTriplesDeleted_,
tracer);
tracer.beginTrace("externalPermutation");
modifyTriplesImpl(cancellationHandle, std::move(triples), true,
triplesInserted_, triplesDeleted_, tracer);
tracer.endTrace("externalPermutation");
tracer.beginTrace("internalPermutation");
modifyTriplesImpl(std::move(cancellationHandle), std::move(internalTriples),
true, internalTriplesInserted_, internalTriplesDeleted_,
tracer);
tracer.endTrace("internalPermutation");

The same for deleteTriples. Some deduplication of these functions would be nice at this point.

@sparql-conformance
Copy link

Overview

Number of Tests Passed ✅ Intended ✅ Failed ❌ Not tested
525 379 67 79 0

Conformance check passed ✅

No test result changes.

Details: https://qlever.dev/sparql-conformance-ui?cur=55dc98e66a8f94972a19e3cda858fb2d172d9895&prev=50d08bc03a4c1fe7495d4209a3542c90ce36b997

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants