From 4c88f0a081b0199149e06b1daad7f0d678641e0c Mon Sep 17 00:00:00 2001 From: Andreas Schultz Date: Mon, 23 Nov 2020 15:52:02 +0100 Subject: [PATCH] Do not add limit or offset when not needed in SPARQL queries --- .../dataset/rdf/endpoint/PagingSparqlTraversable.scala | 8 ++++++-- .../dataset/rdf/endpoint/RemoteSparqlEndpoint.scala | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/silk-plugins/silk-plugins-rdf/src/main/scala/org/silkframework/plugins/dataset/rdf/endpoint/PagingSparqlTraversable.scala b/silk-plugins/silk-plugins-rdf/src/main/scala/org/silkframework/plugins/dataset/rdf/endpoint/PagingSparqlTraversable.scala index 2fb206f89c..e008330133 100644 --- a/silk-plugins/silk-plugins-rdf/src/main/scala/org/silkframework/plugins/dataset/rdf/endpoint/PagingSparqlTraversable.scala +++ b/silk-plugins/silk-plugins-rdf/src/main/scala/org/silkframework/plugins/dataset/rdf/endpoint/PagingSparqlTraversable.scala @@ -65,8 +65,12 @@ object PagingSparqlTraversable { if(Thread.currentThread().isInterrupted) { return } - parsedQuery.setLimit(math.min(params.pageSize, limit - offset)) - parsedQuery.setOffset(offset) + if(params.pageSize != Int.MaxValue && limit > params.pageSize) { + parsedQuery.setOffset(offset) + } + if(limit != Int.MaxValue || params.pageSize != Int.MaxValue) { + parsedQuery.setLimit(math.min(params.pageSize, limit - offset)) + } val inputStream = executeQuery(parsedQuery.serialize(Syntax.syntaxSPARQL_11)) try { val resultCount = outputResults(inputStream, f) diff --git a/silk-plugins/silk-plugins-rdf/src/main/scala/org/silkframework/plugins/dataset/rdf/endpoint/RemoteSparqlEndpoint.scala b/silk-plugins/silk-plugins-rdf/src/main/scala/org/silkframework/plugins/dataset/rdf/endpoint/RemoteSparqlEndpoint.scala index e9ce203445..b1495728be 100644 --- a/silk-plugins/silk-plugins-rdf/src/main/scala/org/silkframework/plugins/dataset/rdf/endpoint/RemoteSparqlEndpoint.scala +++ b/silk-plugins/silk-plugins-rdf/src/main/scala/org/silkframework/plugins/dataset/rdf/endpoint/RemoteSparqlEndpoint.scala @@ -174,4 +174,4 @@ object RemoteSparqlEndpoint { val rt = cfg.getInt("silk.remoteSparqlEndpoint.defaults.read.timeout.ms") (ct, rt) } -} \ No newline at end of file +}