You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by "shin4141 (via GitHub)" <gi...@apache.org> on 2026/10/08 01:54:17 UTC
[PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
shin4141 opened a new pull request, #4314:
URL: https://github.com/apache/jena/pull/4314
GitHub issue resolved #4300
Pull request Description:
SPARQL uses the Unicode code point collation for string comparisons. `XSDFuncOp.compareString` used `String.compareTo`, which compares UTF-16 code units. For example, U+FFFD should sort before U+1D11E, but their UTF-16 order is reversed. This affects string `<`/`>` comparisons and the value-comparison path used for sorting.
Compare one code point at a time, while retaining the existing behavior for equal strings and prefixes. Add regressions for plain and `xsd:string` expression comparisons and `NodeValueSortKey` ordering. The change is confined to three files and adds no dependency or public API.
This follows the [SPARQL 1.1 string collation](https://www.w3.org/TR/sparql11-query/) and the [Unicode Codepoint Collation](https://www.w3.org/2005/xpath-functions/collation/codepoint/).
Validation:
- On `main` at `d77438478938cc651760f4a61e5d9ee7acff072b`, both new regression tests failed. A separate actual-SPARQL probe using U+FFFD, U+FFFE and U+1D11E failed all six checks for `<`, `>`, `ORDER BY`, `MIN()` and `MAX()`; the old order was U+1D11E, U+FFFD, U+FFFE.
- With this change, the two new regression tests and all six actual-SPARQL checks passed. The SPARQL probe is a pre-submit validation artifact outside the three-file PR diff.
- `mvn -B -q -pl jena-arq -am -Dtest=TestGH4300RealSPARQL,TestExpressions2,TestNodeValueSortKey,TestNodeValueOps,TestOrdering,TestSortOrdering,TestComparison,TestStatisticsAggregates,TestNodeValue,TestCustomAggregates -Dsurefire.failIfNoSpecifiedTests=false test` passed: 401 tests including the temporary probe, 0 failures/errors/skips, using Java 21 in an isolated Maven container. The prior 198-test subset remains green.
- `git diff --check` passed.
The full Jena test suite was not run.
----
- [x] Tests are included.
- [ ] Documentation change and updates are provided for the [Apache Jena website](https://github.com/apache/jena-site/) (not needed for this bug fix).
- [ ] Commits have been squashed to remove intermediate development commit messages (local changes are not committed yet).
- [ ] Key commit messages start with the issue number (to complete before submission).
By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).
----
See the [Apache Jena "Contributing" guide](https://github.com/apache/jena/blob/main/CONTRIBUTING.md).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "rvesse (via GitHub)" <gi...@apache.org>.
rvesse commented on code in PR #4314:
URL: https://github.com/apache/jena/pull/4314#discussion_r4216523744
##########
jena-arq/src/test/java/org/apache/jena/sparql/expr/nodevalue/TestNodeValueSortKey.java:
##########
@@ -95,4 +95,12 @@ public void testCompareTo() {
assertEquals(1, nv.compareTo(new NodeValueSortKey("Bonita", "es")));
assertEquals(0, nv.compareTo(new NodeValueSortKey("Bonito", "es")));
}
+
+ @Test
+ public void testCompareToUnicodeCodePointOrder() {
+ NodeValueSortKey bmp = new NodeValueSortKey(Character.toString(0xFFFD), null);
+ NodeValueSortKey astral = new NodeValueSortKey(Character.toString(0x1D11E), null);
+ assertTrue(bmp.compareTo(astral) < 0);
+ assertTrue(astral.compareTo(bmp) > 0);
+ }
Review Comment:
To my comments above it would be useful to add some tests involving code points and one string being a subsequence of the other
##########
jena-arq/src/main/java/org/apache/jena/sparql/expr/nodevalue/XSDFuncOp.java:
##########
@@ -1149,7 +1149,20 @@ public static int compareNumeric(NodeValue nv1, NodeValue nv2) {
// langMatch
public static int compareString(NodeValue nv1, NodeValue nv2) {
- return calcReturn(nv1.getString().compareTo(nv2.getString()));
+ String s1 = nv1.getString();
+ String s2 = nv2.getString();
+ int i1 = 0;
+ int i2 = 0;
+ // SPARQL uses Unicode code point order, not UTF-16 code unit order.
+ while ( i1 < s1.length() && i2 < s2.length() ) {
+ int cp1 = s1.codePointAt(i1);
+ int cp2 = s2.codePointAt(i2);
+ if ( cp1 != cp2 )
+ return calcReturn(Integer.compare(cp1, cp2));
+ i1 += Character.charCount(cp1);
+ i2 += Character.charCount(cp2);
+ }
+ return calcReturn(Integer.compare(s1.length() - i1, s2.length() - i2));
Review Comment:
This last bit of the method looks wrong/odd to me based on your description of the problem being fixed. The rest of the string is compared by code points and then if everything up to the end of one/both strings compares the same you're comparing the length minus the indexes??
I guess the intent here is that if you have one string which is a substring of the other then the shorter one comes first in the sort order? Might be worth an explanatory comment if that is the case
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "afs (via GitHub) via pr" <pr...@jena.apache.org>.
afs merged PR #4314:
URL: https://github.com/apache/jena/pull/4314
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #4314:
URL: https://github.com/apache/jena/pull/4314#issuecomment-6275787348
This is important code!
Please can we have a new test class that focuses on the code of this PR.
`TestCompareStrings` with good coverage for `Expr.CMP_GREATER`, `Expr.CMP_EQUAL, and `Expr.CMP_LESS`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #4314:
URL: https://github.com/apache/jena/pull/4314#discussion_r4348697315
##########
jena-arq/src/test/java/org/apache/jena/sparql/expr/TestCompareStrings.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.apache.jena.sparql.expr;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.sparql.expr.nodevalue.XSDFuncOp;
+
+/** Comparisons of RDF strings in Unicode code point order. */
+public class TestCompareStrings {
+ private static final String BMP = Character.toString(0xFFFD);
Review Comment:
This is not a great choice. U+FFFD is the replacement character.
Would `U+FFE0` work (it's Character: `¢` / Name: FULLWIDTH CENT SIGN)?
##########
jena-arq/src/test/java/org/apache/jena/sparql/expr/TestGH4300LangString.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.apache.jena.sparql.expr;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.jena.query.DatasetFactory;
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.query.QueryExecutionFactory;
+import org.apache.jena.query.ResultSet;
+
+public class TestGH4300LangString {
Review Comment:
Unusual name for this repo - suggestion - `TestCompareLangString`
##########
jena-arq/src/test/java/org/apache/jena/sparql/expr/TS_Expr.java:
##########
@@ -34,6 +34,8 @@
, TestNodeValue.class
, TestExpressions.class
, TestExpressions2.class
+ , TestGH4300LangString.class
+ , TestCompareStrings.class
, TestExpressions3.class
, TestExpressions4.class
Review Comment:
A bit of systematic ordering and naming:
```suggestion
, TestExpressions2.class
, TestExpressions3.class
, TestExpressions4.class
, TestCompareStrings.class
, TestCompareLangString.class
```
##########
jena-arq/src/test/java/org/apache/jena/sparql/expr/TestCompareStrings.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.apache.jena.sparql.expr;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.sparql.expr.nodevalue.XSDFuncOp;
+
+/** Comparisons of RDF strings in Unicode code point order. */
+public class TestCompareStrings {
+ private static final String BMP = Character.toString(0xFFFD);
Review Comment:
Same for other FFFD
##########
jena-arq/src/test/java/org/apache/jena/sparql/expr/TestCompareStrings.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.apache.jena.sparql.expr;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.jena.datatypes.xsd.XSDDatatype;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.sparql.expr.nodevalue.XSDFuncOp;
+
+/** Comparisons of RDF strings in Unicode code point order. */
+public class TestCompareStrings {
+ private static final String BMP = Character.toString(0xFFFD);
+ private static final String SUPPLEMENTARY = Character.toString(0x1D11E);
+ private static final String LATER_SUPPLEMENTARY = Character.toString(0x1F600);
+
+ @Test public void bmpBeforeSupplementary() {
+ // UTF-16 code unit order gives the opposite result for this pair.
+ compare(BMP, SUPPLEMENTARY, Expr.CMP_LESS);
+ compare(SUPPLEMENTARY, BMP, Expr.CMP_GREATER);
+ compare("a" + BMP, "a" + SUPPLEMENTARY, Expr.CMP_LESS);
+ }
+
+ @Test public void supplementaryCodePoints() {
+ compare(SUPPLEMENTARY, LATER_SUPPLEMENTARY, Expr.CMP_LESS);
+ compare("a" + SUPPLEMENTARY + "a", "a" + SUPPLEMENTARY + "b", Expr.CMP_LESS);
+ }
+
+ @Test public void equalStrings() {
+ compare("", "", Expr.CMP_EQUAL);
+ compare(SUPPLEMENTARY + BMP, new String(SUPPLEMENTARY + BMP), Expr.CMP_EQUAL);
Review Comment:
Style: `new String(String)` isn't needed
```suggestion
compare(SUPPLEMENTARY + BMP, SUPPLEMENTARY + BMP, Expr.CMP_EQUAL);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #4314:
URL: https://github.com/apache/jena/pull/4314#issuecomment-6061660374
Looks good.
> SPARQL uses the Unicode code point collation for string comparisons.
We have had a lot of discussion in the working groups about this. It is important to get the terminology sorted out, and Unicode has itself changed over time, so for anyone reading this in the future ...
RDF Concepts defines "RDF string", which is used for the literal lexical form:
> RDF string, or simply [string](https://www.w3.org/TR/rdf12-concepts/#dfn-rdf-string), is used to describe an ordered sequence of zero or more [Unicode code points](https://www.w3.org/TR/i18n-glossary/#dfn-code-point) which are [Unicode scalar values](https://www.w3.org/TR/i18n-glossary/#dfn-scalar-value). Unicode scalar values do not include the [surrogate code points](https://www.w3.org/TR/i18n-glossary/#dfn-surrogate).
Surrogates are code points.
"scalar values" - is the concept that excludes the surrogates. Java's "codepoint" usage is really a scalar value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "shin4141 (via GitHub)" <gi...@apache.org>.
shin4141 commented on code in PR #4314:
URL: https://github.com/apache/jena/pull/4314#discussion_r4216820771
##########
jena-arq/src/main/java/org/apache/jena/sparql/expr/nodevalue/XSDFuncOp.java:
##########
@@ -1149,7 +1149,20 @@ public static int compareNumeric(NodeValue nv1, NodeValue nv2) {
// langMatch
public static int compareString(NodeValue nv1, NodeValue nv2) {
- return calcReturn(nv1.getString().compareTo(nv2.getString()));
+ String s1 = nv1.getString();
+ String s2 = nv2.getString();
+ int i1 = 0;
+ int i2 = 0;
+ // SPARQL uses Unicode code point order, not UTF-16 code unit order.
+ while ( i1 < s1.length() && i2 < s2.length() ) {
+ int cp1 = s1.codePointAt(i1);
+ int cp2 = s2.codePointAt(i2);
+ if ( cp1 != cp2 )
+ return calcReturn(Integer.compare(cp1, cp2));
+ i1 += Character.charCount(cp1);
+ i2 += Character.charCount(cp2);
+ }
+ return calcReturn(Integer.compare(s1.length() - i1, s2.length() - i2));
Review Comment:
You're right: when the loop ends, at least one string is exhausted and all preceding code points matched. The remaining-length comparison therefore only determines whether either string has a suffix; that string sorts after its matching prefix (both zero means equal). I added a one-line explanation above the return in b84de790, with no logic change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "shin4141 (via GitHub)" <gi...@apache.org>.
shin4141 commented on code in PR #4314:
URL: https://github.com/apache/jena/pull/4314#discussion_r4216822556
##########
jena-arq/src/test/java/org/apache/jena/sparql/expr/nodevalue/TestNodeValueSortKey.java:
##########
@@ -95,4 +95,12 @@ public void testCompareTo() {
assertEquals(1, nv.compareTo(new NodeValueSortKey("Bonita", "es")));
assertEquals(0, nv.compareTo(new NodeValueSortKey("Bonito", "es")));
}
+
+ @Test
+ public void testCompareToUnicodeCodePointOrder() {
+ NodeValueSortKey bmp = new NodeValueSortKey(Character.toString(0xFFFD), null);
+ NodeValueSortKey astral = new NodeValueSortKey(Character.toString(0x1D11E), null);
+ assertTrue(bmp.compareTo(astral) < 0);
+ assertTrue(astral.compareTo(bmp) > 0);
+ }
Review Comment:
I added `testCompareToUnicodeCodePointPrefix` in b84de790. It checks a U+1D11E prefix against U+1D11E followed by `a` in both directions, a separate equal-string instance, and empty-string comparisons. The old UTF-16 comparator already handled prefixes correctly, so this characterizes the tail case rather than reproducing the code-point bug; the U+FFFD versus U+1D11E regression remains. The Java 21 clean build and related SPARQL/ARQ tests passed (402/402).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "OyvindLGjesdal (via GitHub)" <gi...@apache.org>.
OyvindLGjesdal commented on PR #4314:
URL: https://github.com/apache/jena/pull/4314#issuecomment-6279135291
> I kept the existing comparison path for VSPACE_STRING rather than switching to String.equals, since the current approach is consistent with the other comparisons.
Thank you @shin4141. My `equals` suggestion came from a JMH-run that called the comparator directly. That skipped the fast path in `sameValueAs`, which returns early for identical RDF terms, so equal strings never reach `compareString`. Keeping the current code works.
Measured through Jena (main vs the PR's `XSDFuncOp` + `NVCompare`) on literals from the Wikidata lexemes dump, it is close to main (and correct):
| Operation | Data | main | PR |
|---|---|---|---|
| `ORDER BY` (`compareAlways`, sort 100k) | `@lang` | 241 ms ±8 | 249 ms ±29 (no measurable difference) |
| `ORDER BY` (`compareAlways`, sort 100k) | `xsd:string` | 41.7 ms ±1.8 | 45.4 ms ±4.0 (+9%) |
| `<` (`compare`), same language tag | `@lang` | 38.2 ns | 41.7 ns (+9%) |
| `<` (`compare`) | `xsd:string` | 30.7 ns | 28.7 ns (≈) |
| `=` (`sameValueAs`), equal values | `@lang` | 3.0 ns | 3.0 ns |
| `=` (`sameValueAs`), equal values | `xsd:string` | 31.3 ns | 31.4 ns |
(JMH 1.37, JDK 21, 2 forks × 5 iterations, laptop on battery.)
for reference: https://github.com/apache/jena/compare/main...OyvindLGjesdal:jena:gh-4300-strcmp-benchmarks?expand=1
One case that could be worth a follow up @afs :
For long `xsd:string` values with a shared prefix, such as URLs or `STR(?iri)`. Measured through Jena on IRI text from the same dump, the PR sorts these about 2.5x slower than main (113 ms vs 46 ms per 100k values), and `=` on unequal values is about 2.7x slower. (see more in the benchmark branch above)
This is because the loop has to walk the shared prefix.
However I think this is a bigger change since as you mentioned @shin4141 the comparison follows the same pattern, and would further change the current logic of how Expr.CMP_EQUAL now works.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "OyvindLGjesdal (via GitHub)" <gi...@apache.org>.
OyvindLGjesdal commented on PR #4314:
URL: https://github.com/apache/jena/pull/4314#issuecomment-6133989986
Thank you for the report and PR @shin4141 and for the ping @rvesse
I have some comments:
I think the equality comparison for `IN`, `=` `!=` now decodes the codepoints and compares, when it could just check for equality, so maybe
https://github.com/apache/jena/blob/c490a5729d5f07d2eec25ac6cdb1354a09c97685/jena-arq/src/main/java/org/apache/jena/sparql/expr/NVCompare.java#L92
could be replaced with
```java
case VSPACE_STRING :
return nv1.getString().equals(nv2.getString());
```
Given the spec of XSD I am not sure if this case holds.
In addition the bug also applies to language-tagged literals (`rdf:langString`) with the same language tag. Should this PR just fix the string case, or also handle that?
https://github.com/apache/jena/blob/c490a5729d5f07d2eec25ac6cdb1354a09c97685/jena-arq/src/main/java/org/apache/jena/sparql/expr/NVCompare.java#L317
With this PR applied, `'\uFFFD' < '\U0001D11E'` is true/fixed, but `'\uFFFD'@en < '\U0001D11E'@en` is still false, and `ORDER BY` over `@en` strings still puts `\U0001D11E` before `\uFFFD`. Should this PR fix that too, or just the string case?
What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "shin4141 (via GitHub)" <gi...@apache.org>.
shin4141 commented on PR #4314:
URL: https://github.com/apache/jena/pull/4314#issuecomment-6190466637
Thanks, @OyvindLGjesdal. I fixed the same-language `rdf:langString` case in 61804b5. It now uses `XSDFuncOp.compareString`, with `<`, `>`, and `ORDER BY` regression tests.
I kept the existing comparison path for `VSPACE_STRING` rather than switching to `String.equals`, since the current approach is consistent with the other comparisons.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-4300: Compare SPARQL strings by Unicode code point [jena]
Posted by "afs (via GitHub) via pr" <pr...@jena.apache.org>.
afs commented on PR #4314:
URL: https://github.com/apache/jena/pull/4314#issuecomment-6546770205
@shin4141 -- thank you.
In reviewing these changes, I found some nearby comparison problems.
Follow-on work: https://github.com/apache/jena/issues/4365
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org