Skip to content

Commit

Permalink
implement evaluation of no-cache option in DatasetGraphCreator -- see #…
Browse files Browse the repository at this point in the history
…371

update test #371 #372
  • Loading branch information
luigi-asprino committed Jun 9, 2023
1 parent 95b2f86 commit e35c237
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
22 changes: 16 additions & 6 deletions sparql-anything-it/src/test/resources/issues/issue371.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
CONSTRUCT {?s ?p ?o} WHERE {

service <x-sparql-anything:spreadsheet.evaluate-formulas=true>
{
SELECT * WHERE {
SERVICE <x-sparql-anything:spreadsheet.evaluate-formulas=true> {
fx:properties fx:location "%%%LOCATION%%%" .
?s ?p ?o
}
[] rdf:type fx:root ;
fx:anySlot ?row .
?row rdf:_1 ?n .
?row rdf:_2 ?now

SERVICE <x-sparql-anything:> {


fx:properties fx:content "[1.0,2.0,3.0]" .
fx:properties fx:media-type "application/json" .
?s fx:anySlot ?n .
}


}
}
Binary file modified sparql-anything-it/src/test/resources/issues/issue371.xls
Binary file not shown.

0 comments on commit e35c237

Please sign in to comment.