-
Notifications
You must be signed in to change notification settings - Fork 54
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
base: master
Are you sure you want to change the base?
Correct datatypes for string expressions #1636
Conversation
Co-authored-by: Johannes Kalmbach <[email protected]>
Co-authored-by: Johannes Kalmbach <[email protected]>
Update from original Qlever
Codecov ReportAttention: Patch coverage is
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. |
Hi, You can above click at |
There was a problem hiding this 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.
There was a problem hiding this 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.)
EXPECT_EQ(resultLiteral.value().toStringRepresentation(), "\"something\""); | ||
// Case onlyReturnLiterals | ||
resultLiteral = ExportQueryExecutionTrees::idToLiteralOrIri<true>( |
There was a problem hiding this comment.
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.
# Conflicts: # src/engine/sparqlExpressions/StringExpressions.cpp
There was a problem hiding this 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."); |
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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_CHECK
s here that the start
and length
are in the correct ranges
(including letting them fail in the unit tests).
content_.erase(beginOfSuffix_); | ||
beginOfSuffix_ = content_.size(); |
There was a problem hiding this comment.
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]>
Conformance check passed ✅Test Status Changes 📊
|
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
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?