You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2022/12/19 15:24:21 UTC

[GitHub] [jena] Aklakan opened a new pull request, #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Aklakan opened a new pull request, #1689:
URL: https://github.com/apache/jena/pull/1689

   GitHub issue resolved #1688
   
   Pull request Description: Fixes registration of an empty iterator in case a cache hit reveals an empty result set.
   
   ----
   
    - [ ] Tests are included.
    - ~~[ ] Documentation change and updates are provided for the [Apache Jena website](https://github.com/apache/jena-site/)~~
    - [x] Commits have been squashed to remove intermediate development commit messages.
    - [x] Key commit messages start with the issue number (GH-xxxx or JENA-xxxx)
   
   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


[GitHub] [jena] Aklakan commented on a diff in pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
Aklakan commented on code in PR #1689:
URL: https://github.com/apache/jena/pull/1689#discussion_r1053231420


##########
jena-extras/jena-serviceenhancer/src/main/java/org/apache/jena/sparql/service/enhancer/impl/RequestExecutor.java:
##########
@@ -109,60 +109,60 @@ protected Binding moveToNext() {
         // Peek the next binding on the active iterator and verify that it maps to the current
         // partition key
         while (true) {
-          if (activeIter.hasNext()) {

Review Comment:
   Fix of indentation - changed 2 spaces to 4.



-- 
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


[GitHub] [jena] Aklakan commented on a diff in pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
Aklakan commented on code in PR #1689:
URL: https://github.com/apache/jena/pull/1689#discussion_r1053230289


##########
jena-extras/jena-serviceenhancer/src/main/java/org/apache/jena/sparql/service/enhancer/impl/util/VarScopeUtils.java:
##########
@@ -37,29 +37,6 @@
  */
 public class VarScopeUtils {
 
-    public static Map<Var, Var> reverseVarRenameMap(Collection<Var> vars) {

Review Comment:
   Moved these block of methods to the end of the class - probably they can be eventually removed.



-- 
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


[GitHub] [jena] afs commented on a diff in pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
afs commented on code in PR #1689:
URL: https://github.com/apache/jena/pull/1689#discussion_r1053103859


##########
jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerMisc.java:
##########
@@ -462,4 +470,55 @@ public void testNormalization01() {
         int actualRowCount = AbstractTestServiceEnhancerResultSetLimits.testWithCleanCaches(dataset, queryStr, 1000);
         Assert.assertEquals(4, actualRowCount);
     }
+
+    /**
+     * Test for <a href="https://github.com/apache/jena/issues/1688">/issues/1688</a>.
+     * <p>
+     * This test checks that building an overall result set from a bulk request
+     * that involves contributions of cached empty result sets works as expected.
+     * Without the fix corresponding to this issues this test fails.
+     *
+     * @implNote This test case makes use of a dataset where only a few resources have labels.
+     * The test query caches the labels of all resources which means that most cache entries
+     * have empty results.
+     */
+    @Test
+    public void testBulkRequestsOverCachedEmptyResultSets() {
+        String dataStr = String.join(StandardSystemProperty.LINE_SEPARATOR.value(),
+            "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>",
+            "<urn:example:00> a rdfs:Resource .",
+            "<urn:example:01> a rdfs:Resource .",
+            "<urn:example:02> a rdfs:Resource .",
+            "<urn:example:03> a rdfs:Resource .",
+            "<urn:example:04> a rdfs:Resource ; rdfs:label '04' .",
+            "<urn:example:05> a rdfs:Resource .",
+            "<urn:example:06> a rdfs:Resource .",
+            "<urn:example:07> a rdfs:Resource .",
+            "<urn:example:08> a rdfs:Resource ; rdfs:label '08' .",
+            "<urn:example:09> a rdfs:Resource ; rdfs:label '09' .");
+
+        String queryStr = String.join(StandardSystemProperty.LINE_SEPARATOR.value(),
+            "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>",
+            "SELECT * {",
+            "  { SELECT * { ?s a rdfs:Resource } ORDER BY ?s }",
+            "   SERVICE <loop:cache:bulk+5> { ?s rdfs:label ?l }",
+            "}");
+
+        Dataset ds = DatasetFactory.create();
+        RDFDataMgr.read(ds, new StringReader(dataStr), null, Lang.TURTLE);

Review Comment:
   FYI:
   `RDFParser.fromString(dataStr).lang(Lang.TURTLE).toDataset();`



-- 
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


[GitHub] [jena] afs commented on pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
afs commented on PR #1689:
URL: https://github.com/apache/jena/pull/1689#issuecomment-1359138835

   @LorenzBuehmann - thanks for checking - it's "draft" though.
   
   If in the next 2 hours that changes I (as release manager) will consider it for 4.7.0. The release testing has already been done, bots have already run on different OS etc  - it must be clean.
   


-- 
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


[GitHub] [jena] Aklakan commented on a diff in pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
Aklakan commented on code in PR #1689:
URL: https://github.com/apache/jena/pull/1689#discussion_r1052642681


##########
jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerMisc.java:
##########
@@ -462,4 +471,55 @@ public void testNormalization01() {
         int actualRowCount = AbstractTestServiceEnhancerResultSetLimits.testWithCleanCaches(dataset, queryStr, 1000);
         Assert.assertEquals(4, actualRowCount);
     }
+
+    /**
+     * Test for <a href="https://github.com/apache/jena/issues/1688">JENA-1688</a>.

Review Comment:
   Right - updated as suggested :)



-- 
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


[GitHub] [jena] Aklakan commented on a diff in pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
Aklakan commented on code in PR #1689:
URL: https://github.com/apache/jena/pull/1689#discussion_r1053230289


##########
jena-extras/jena-serviceenhancer/src/main/java/org/apache/jena/sparql/service/enhancer/impl/util/VarScopeUtils.java:
##########
@@ -37,29 +37,6 @@
  */
 public class VarScopeUtils {
 
-    public static Map<Var, Var> reverseVarRenameMap(Collection<Var> vars) {

Review Comment:
   Moved these methods to the end of the class - probably they can be eventually removed.



-- 
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


[GitHub] [jena] afs merged pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
afs merged PR #1689:
URL: https://github.com/apache/jena/pull/1689


-- 
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


[GitHub] [jena] afs commented on a diff in pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
afs commented on code in PR #1689:
URL: https://github.com/apache/jena/pull/1689#discussion_r1052604955


##########
jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerMisc.java:
##########
@@ -38,6 +46,7 @@
 import org.apache.jena.sparql.engine.binding.BindingFactory;
 import org.apache.jena.sparql.service.enhancer.algebra.TransformSE_JoinStrategy;
 import org.apache.jena.sparql.service.enhancer.init.ServiceEnhancerConstants;
+import org.apache.jena.sparql.service.enhancer.init.ServiceEnhancerInit;

Review Comment:
   Unused.



-- 
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


[GitHub] [jena] LorenzBuehmann commented on pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
LorenzBuehmann commented on PR #1689:
URL: https://github.com/apache/jena/pull/1689#issuecomment-1358936379

   I can confirm that the issue I spotted yesterday has been resolved when using the PR code. Thanks.


-- 
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


[GitHub] [jena] Aklakan commented on a diff in pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
Aklakan commented on code in PR #1689:
URL: https://github.com/apache/jena/pull/1689#discussion_r1053236048


##########
jena-extras/jena-serviceenhancer/src/main/java/org/apache/jena/sparql/service/enhancer/impl/OpServiceInfo.java:
##########
@@ -93,7 +93,7 @@ public OpServiceInfo(OpService opService) {
 
         // Handling of a null supOp - can that happen?
         Set<Var> visibleSubOpVars = OpVars.visibleVars(baseSubOp);
-        this.visibleSubOpVarsScopedToNorm = VarScopeUtils.normalizeVarScopesGlobal(visibleSubOpVars);

Review Comment:
   This one-liner fixes a scoping issue @LorenzBuehmann found just after he reported that this PR works while trying variants of the query that led to this PR. Instead of cut-off results it may lead to missing columns.



-- 
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


[GitHub] [jena] Aklakan commented on a diff in pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
Aklakan commented on code in PR #1689:
URL: https://github.com/apache/jena/pull/1689#discussion_r1052639293


##########
jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerMisc.java:
##########
@@ -462,4 +471,55 @@ public void testNormalization01() {
         int actualRowCount = AbstractTestServiceEnhancerResultSetLimits.testWithCleanCaches(dataset, queryStr, 1000);
         Assert.assertEquals(4, actualRowCount);
     }
+
+    /**
+     * Test for <a href="https://github.com/apache/jena/issues/1688">JENA-1688</a>.
+     * <p>
+     * This test checks that building an overall result set from a bulk request
+     * that involves contributions of cached empty result sets works as expected.
+     * Without the fix corresponding to this issues this test fails.
+     *
+     * @implNote This test case makes use of a dataset where only a few resources have labels.
+     * The test query caches the labels of all resources which means that most cache entries
+     * have empty results.
+     */
+    @Test
+    public void testEmptyResultSetContribution() {
+        String dataStr = String.join(StandardSystemProperty.LINE_SEPARATOR.value(),

Review Comment:
   Isn't it the case that on Windows or Mac a plain "\n" could lead to incorrect formatting when `System.out.println`-ing?
   If you prefer "\n" then I am also fine with it.



-- 
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


[GitHub] [jena] Aklakan commented on pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
Aklakan commented on PR #1689:
URL: https://github.com/apache/jena/pull/1689#issuecomment-1358407434

   Overall this PR should be complete and  but I'd like @LorenzBuehmann to give this PR a final test himself tomorrow.


-- 
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


[GitHub] [jena] afs commented on a diff in pull request #1689: GH-1688 Fix possible incomplete results with service enhaner caching + bulk

Posted by GitBox <gi...@apache.org>.
afs commented on code in PR #1689:
URL: https://github.com/apache/jena/pull/1689#discussion_r1052595464


##########
jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerMisc.java:
##########
@@ -462,4 +471,55 @@ public void testNormalization01() {
         int actualRowCount = AbstractTestServiceEnhancerResultSetLimits.testWithCleanCaches(dataset, queryStr, 1000);
         Assert.assertEquals(4, actualRowCount);
     }
+
+    /**
+     * Test for <a href="https://github.com/apache/jena/issues/1688">JENA-1688</a>.
+     * <p>
+     * This test checks that building an overall result set from a bulk request
+     * that involves contributions of cached empty result sets works as expected.
+     * Without the fix corresponding to this issues this test fails.
+     *
+     * @implNote This test case makes use of a dataset where only a few resources have labels.
+     * The test query caches the labels of all resources which means that most cache entries
+     * have empty results.
+     */
+    @Test
+    public void testEmptyResultSetContribution() {
+        String dataStr = String.join(StandardSystemProperty.LINE_SEPARATOR.value(),

Review Comment:
   Not critical but why not "\n"? SPARQL is a web language.
   



##########
jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerMisc.java:
##########
@@ -462,4 +471,55 @@ public void testNormalization01() {
         int actualRowCount = AbstractTestServiceEnhancerResultSetLimits.testWithCleanCaches(dataset, queryStr, 1000);
         Assert.assertEquals(4, actualRowCount);
     }
+
+    /**
+     * Test for <a href="https://github.com/apache/jena/issues/1688">JENA-1688</a>.

Review Comment:
   JENA-1688 is a JIRA from 2019!
   Try: "apache/jena/issues/1688"



##########
jena-extras/jena-serviceenhancer/src/test/java/org/apache/jena/sparql/service/enhancer/impl/TestServiceEnhancerMisc.java:
##########
@@ -462,4 +471,55 @@ public void testNormalization01() {
         int actualRowCount = AbstractTestServiceEnhancerResultSetLimits.testWithCleanCaches(dataset, queryStr, 1000);
         Assert.assertEquals(4, actualRowCount);
     }
+
+    /**
+     * Test for <a href="https://github.com/apache/jena/issues/1688">JENA-1688</a>.
+     * <p>
+     * This test checks that building an overall result set from a bulk request
+     * that involves contributions of cached empty result sets works as expected.
+     * Without the fix corresponding to this issues this test fails.
+     *
+     * @implNote This test case makes use of a dataset where only a few resources have labels.
+     * The test query caches the labels of all resources which means that most cache entries
+     * have empty results.
+     */
+    @Test
+    public void testEmptyResultSetContribution() {
+        String dataStr = String.join(StandardSystemProperty.LINE_SEPARATOR.value(),
+            "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>",
+            "<urn:example:00> a rdfs:Resource .",
+            "<urn:example:01> a rdfs:Resource .",
+            "<urn:example:02> a rdfs:Resource .",
+            "<urn:example:03> a rdfs:Resource .",
+            "<urn:example:04> a rdfs:Resource ; rdfs:label \"04\" .",
+            "<urn:example:05> a rdfs:Resource .",
+            "<urn:example:06> a rdfs:Resource .",
+            "<urn:example:07> a rdfs:Resource .",
+            "<urn:example:08> a rdfs:Resource ; rdfs:label \"08\" .",

Review Comment:
   FYI: use single quotes to neaten up -`'08'`.



-- 
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