From e35c237f608803be7bc7714227534ef3ba3d2b0a Mon Sep 17 00:00:00 2001 From: Luigi Asprino Date: Fri, 9 Jun 2023 12:20:38 +0200 Subject: [PATCH] implement evaluation of no-cache option in DatasetGraphCreator -- see #371 update test #371 #372 --- .../engine/DatasetGraphCreator.java | 7 ++++-- .../github/sparqlanything/it/IssuesTest.java | 17 +++++++------- .../src/test/resources/issues/issue371.sparql | 22 +++++++++++++----- .../src/test/resources/issues/issue371.xls | Bin 26112 -> 26112 bytes 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/sparql-anything-engine/src/main/java/io/github/sparqlanything/engine/DatasetGraphCreator.java b/sparql-anything-engine/src/main/java/io/github/sparqlanything/engine/DatasetGraphCreator.java index de8819de..6789109b 100644 --- a/sparql-anything-engine/src/main/java/io/github/sparqlanything/engine/DatasetGraphCreator.java +++ b/sparql-anything-engine/src/main/java/io/github/sparqlanything/engine/DatasetGraphCreator.java @@ -67,10 +67,13 @@ public DatasetGraph getDatasetGraph(Triplifier t, Properties p, Op op) throws IO if (t == null) { return DatasetGraphFactory.create(); } + + boolean use_cache = !PropertyUtils.getBooleanProperty(p, IRIArgument.NO_CACHE); + logger.trace("Use cache {}",use_cache); // If the operation was already executed in a previous call, reuse the same // in-memory graph // XXX Future implementations may use a caching system - if (executedFacadeXIris.containsKey(getInMemoryCacheKey(p, op))) + if (use_cache && executedFacadeXIris.containsKey(getInMemoryCacheKey(p, op))) return executedFacadeXIris.get(getInMemoryCacheKey(p, op)); logger.trace("Properties extracted: {}", p); @@ -100,7 +103,7 @@ public DatasetGraph getDatasetGraph(Triplifier t, Properties p, Op op) throws IO dg.commit(); } // Remember the triplified data - if (!executedFacadeXIris.containsKey(getInMemoryCacheKey(p, op))) { + if (use_cache && !executedFacadeXIris.containsKey(getInMemoryCacheKey(p, op))) { executedFacadeXIris.put(getInMemoryCacheKey(p, op), dg); logger.debug("Graph added to in-memory cache"); } diff --git a/sparql-anything-it/src/test/java/io/github/sparqlanything/it/IssuesTest.java b/sparql-anything-it/src/test/java/io/github/sparqlanything/it/IssuesTest.java index 266c6a28..0e4114fc 100644 --- a/sparql-anything-it/src/test/java/io/github/sparqlanything/it/IssuesTest.java +++ b/sparql-anything-it/src/test/java/io/github/sparqlanything/it/IssuesTest.java @@ -763,14 +763,15 @@ public void testIssue371() throws URISyntaxException, IOException { query = QueryFactory.create(queryStr); QueryExecution qExec1 = QueryExecutionFactory.create(query, ds); - QueryExecution qExec2 = QueryExecutionFactory.create(query, ds); -// System.out.println(ResultSetFormatter.asText(qExec1.execSelect())); - - Model m1 = qExec1.execConstruct(); - m1.write(System.out, "TTL"); - Model m2 = qExec2.execConstruct(); - m2.write(System.out, "TTL"); - Assert.assertFalse(m1.isIsomorphicWith(m2)); +// QueryExecution qExec2 = QueryExecutionFactory.create(query, ds); + System.out.println(ResultSetFormatter.asText(qExec1.execSelect())); + System.out.println(query.toString(Syntax.defaultSyntax)); + +// Model m1 = qExec1.execConstruct(); +// m1.write(System.out, "TTL"); +// Model m2 = qExec2.execConstruct(); +// m2.write(System.out, "TTL"); +// Assert.assertFalse(m1.isIsomorphicWith(m2)); // Assert.assertTrue(qExec.execSelect().hasNext()); diff --git a/sparql-anything-it/src/test/resources/issues/issue371.sparql b/sparql-anything-it/src/test/resources/issues/issue371.sparql index bc649eca..57fa31d0 100644 --- a/sparql-anything-it/src/test/resources/issues/issue371.sparql +++ b/sparql-anything-it/src/test/resources/issues/issue371.sparql @@ -2,12 +2,22 @@ PREFIX fx: PREFIX xyz: PREFIX rdf: PREFIX rdfs: -CONSTRUCT {?s ?p ?o} WHERE { - - service - { +SELECT * WHERE { + SERVICE { fx:properties fx:location "%%%LOCATION%%%" . - ?s ?p ?o - } + [] rdf:type fx:root ; + fx:anySlot ?row . + ?row rdf:_1 ?n . + ?row rdf:_2 ?now + + SERVICE { + + fx:properties fx:content "[1.0,2.0,3.0]" . + fx:properties fx:media-type "application/json" . + ?s fx:anySlot ?n . + } + + + } } \ No newline at end of file diff --git a/sparql-anything-it/src/test/resources/issues/issue371.xls b/sparql-anything-it/src/test/resources/issues/issue371.xls index 74a7723fb2514a25a93c64523e7b24ae11ddac9e..91633e9a954b33c326162923ac490d3d5a56674a 100644 GIT binary patch delta 349 zcmZoT!`N_!aRZwXBll!>qhNjx1{nCyz{J3@xyI-i51XPL1A~G6WDolvjEs{V9mMOI zfQmSn1i(s}7#tYE3`Tyi7>I)|22zhM#*8Lb$HWCTh95|NuxDeC1=5TRb_|N_|Gu7O zeg?7RFFS)IBSSrdqZb26J;*MQdIkrOdPWTOjQ_#vVah?y04e7HD`!Ge4%Ge+uAGsH zjRE9BJBI5FJPgl)EE@)WFtlS5ntaPaha2i?kgbyi9or^3y=B?(jbZ!dk524LjB_^s IOkrmP05p{}8vp7j$RCZffh0_Ff#Cil|gt+Kpx0cMkY3(VGIm*4A+5<$_KJU7;G6P uJ2>idvx1c~GO#kRPOfrnn=Ig*ImziQ%hJV1MK*tQVpn1`-uyF#oe=