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

Correct datatypes for string expressions #1636

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

DuDaAG
Copy link
Contributor

@DuDaAG DuDaAG commented Nov 22, 2024

Ich weiß leider immer noch nicht, wie ich ich zum Testen ein Literal mit Datatype erzeugen kann.

Also in Zeile ExportExecutionTreesTest.cpp Zeile 1678 + Zeile 1686.

Gibt es hier in Github die Möglichkeit, dass ich zu einzelnen Codestellen Kommentare (Fragen an dich) einfüge, damit es übersichtlicher ist. Ich habe die Funktion nur in den einzelnen Commits gefunden, aber bis man die dann findet. Also wie mache ich es am besten?

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 38 lines in your changes missing coverage. Please review.

Project coverage is 89.79%. Comparing base (97c195a) to head (40511b3).

Files with missing lines Patch % Lines
src/engine/ExportQueryExecutionTrees.cpp 75.86% 7 Missing and 7 partials ⚠️
...e/sparqlExpressions/SparqlExpressionValueGetters.h 0.00% 9 Missing ⚠️
src/engine/sparqlExpressions/StringExpressions.cpp 84.31% 7 Missing and 1 partial ⚠️
...sparqlExpressions/SparqlExpressionValueGetters.cpp 53.33% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1636      +/-   ##
==========================================
- Coverage   89.84%   89.79%   -0.05%     
==========================================
  Files         389      389              
  Lines       37268    37405     +137     
  Branches     4202     4221      +19     
==========================================
+ Hits        33482    33589     +107     
- Misses       2485     2508      +23     
- Partials     1301     1308       +7     

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

@joka921
Copy link
Member

joka921 commented Nov 22, 2024

Hi, You can above click at Files changed, then you get the changed files (by default from all commits, which is fine for what you want), then you can select rows and attach comments to those. Make sure to finish your(self-review) if the comments are marked as "pending", because otherwise we cannot see them.

test/ExportQueryExecutionTreesTest.cpp Outdated Show resolved Hide resolved
test/ExportQueryExecutionTreesTest.cpp Outdated Show resolved Hide resolved
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 on everything but the tests.
Work on my comments, and contact me once you are done or are left with questions.

src/engine/ExportQueryExecutionTrees.h Outdated Show resolved Hide resolved
src/engine/ExportQueryExecutionTrees.h Outdated Show resolved Hide resolved
src/engine/ExportQueryExecutionTrees.h Outdated Show resolved Hide resolved
src/engine/ExportQueryExecutionTrees.cpp Outdated Show resolved Hide resolved
src/engine/ExportQueryExecutionTrees.cpp Outdated Show resolved Hide resolved
src/engine/sparqlExpressions/StringExpressions.cpp Outdated Show resolved Hide resolved
src/engine/sparqlExpressions/StringExpressions.cpp Outdated Show resolved Hide resolved
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.

Another round of reviews, this is really improving.
Make sure that the continuous integration runs through (in particular no warnings in the code + formatting etc.)

src/parser/LiteralOrIri.cpp Outdated Show resolved Hide resolved
src/engine/ExportQueryExecutionTrees.h Outdated Show resolved Hide resolved
src/engine/ExportQueryExecutionTrees.h Outdated Show resolved Hide resolved
src/engine/ExportQueryExecutionTrees.h Outdated Show resolved Hide resolved
src/engine/ExportQueryExecutionTrees.cpp Outdated Show resolved Hide resolved
src/parser/Literal.cpp Show resolved Hide resolved
test/ExportQueryExecutionTreesTest.cpp Show resolved Hide resolved
Comment on lines 1655 to 1657
EXPECT_EQ(resultLiteral.value().toStringRepresentation(), "\"something\"");
// Case onlyReturnLiterals
resultLiteral = ExportQueryExecutionTrees::idToLiteralOrIri<true>(
Copy link
Member

Choose a reason for hiding this comment

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

There is a lot of code duplication here.
As a first step you can factor out the calls to idToLiteralOrIri (write a lambda that does this for you, such that the calls get shorter.

Then you can look up the gtest matchers ::testing::Optional and ::testing::ResultOf to get this shorter (the googletest documentation, or the rest of the codebase can give you hints, otherwise contact me.

test/SparqlExpressionTest.cpp Outdated Show resolved Hide resolved
test/SparqlExpressionTest.cpp Outdated Show resolved Hide resolved
Annika Greif and others added 7 commits December 12, 2024 12:41
@joka921 joka921 marked this pull request as ready for review December 18, 2024 08:56
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.

some small comments for some of the TODOs.

if (!word.isLiteral()) {
if(onlyReturnLiterals || onlyReturnLiteralsWithXsdString){
if (onlyReturnLiterals || onlyReturnLiteralsWithXsdString) {
AD_THROW("The input is an IRI, but only literals are allowed.");
Copy link
Member

Choose a reason for hiding this comment

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

Is this only for debugging? Or what is wrong with the nullopt return below?

return s;
}
AD_THROW("Input is not a plain string or xsd:string.");
Copy link
Member

Choose a reason for hiding this comment

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

Seems like a debug output.

s.value().getLiteral().setSubstr(clamp(startInt), clamp(lengthInt));
return s.value();
startInt = clamp(startInt);
lengthInt = clamp(lengthInt);
Copy link
Member

Choose a reason for hiding this comment

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

I think you have to use a clamped version of start + length , ottherwise this doesn't quite work.

content_ = absl::StrCat("\"", shortenedContent, "\"", suffix);
beginOfSuffix_ = content_.size() - suffix.size();
void Literal::setSubstr(std::size_t start, std::size_t length) {
std::size_t contentLength = beginOfSuffix_ - 2;
Copy link
Member

Choose a reason for hiding this comment

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

For safety we should have AD_CONTRACT_CHECKs here that the start and length are in the correct ranges
(including letting them fail in the unit tests).

Comment on lines +148 to +149
content_.erase(beginOfSuffix_);
beginOfSuffix_ = content_.size();
Copy link
Member

Choose a reason for hiding this comment

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

This also deletes the language tag if there is a language tag.
Either rename this function (removeDatatypeOrLanguageTag) , or check via AD_CONTRACT_CHECK that you indeed have a datatype.

Signed-off-by: Johannes Kalmbach <[email protected]>
@sparql-conformance
Copy link

Conformance check passed ✅

Test Status Changes 📊

Number of Tests Previous Status Current Status
2 Failed Intended

Details: https://qlever.cs.uni-freiburg.de/sparql-conformance-ui?cur=40511b3f2fc549b1f822d37e87125f80827adfa6&prev=97c195aaf9e249f43a6417f99ea93f7e94831f39

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
5.7% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

2 participants