jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject jena git commit: Allow a query with FROM to pass through to the query engine.
Date Wed, 15 Feb 2017 23:34:19 GMT
Repository: jena
Updated Branches:
  refs/heads/master 8a6505aa4 -> 2757cc47b


Allow a query with FROM to pass through to the query engine.

This combines the old (pre 3.1.0) and current (3.2.0) behaviour.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/2757cc47
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/2757cc47
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/2757cc47

Branch: refs/heads/master
Commit: 2757cc47b4c9f2cfc0ae7a733deaa79534db0aab
Parents: 8a6505a
Author: Andy Seaborne <andy@apache.org>
Authored: Wed Feb 15 23:33:47 2017 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Wed Feb 15 23:33:47 2017 +0000

----------------------------------------------------------------------
 jena-cmds/src/main/java/arq/query.java | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/2757cc47/jena-cmds/src/main/java/arq/query.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/arq/query.java b/jena-cmds/src/main/java/arq/query.java
index 36047a2..f7041e9 100644
--- a/jena-cmds/src/main/java/arq/query.java
+++ b/jena-cmds/src/main/java/arq/query.java
@@ -166,11 +166,16 @@ public class query extends CmdARQ
     @Override
     protected String getSummary() { return getCommandName()+" --data=<file> --query=<query>"
; }
     
-    protected Dataset getDataset()  { 
+    /** Choose the dataset.
+     * <li> use the data as described on the comand line
+     * <li> else use FROM/FROM NAMED if present (pass null to ARQ)
+     * <li> else provided an empty dataset and hope the query has VALUES/BIND
+     */
+    protected Dataset getDataset(Query query)  { 
         try {
             Dataset ds = modDataset.getDataset();
             if ( ds == null )
-                ds = dealWithNoDataset();
+                ds = dealWithNoDataset(query);
             return ds;
         }
         catch (RiotNotFoundException ex) {
@@ -183,8 +188,11 @@ public class query extends CmdARQ
         }
     }
     
-    protected Dataset dealWithNoDataset()  {
-        return DatasetFactory.create() ;
+    // Policy for no command line dataset. null means "whatever" (use FROM) 
+    protected Dataset dealWithNoDataset(Query query)  {
+        if ( query.hasDatasetDescription() )
+            return null;
+        return DatasetFactory.createTxnMem();
         //throw new CmdException("No dataset provided") ; 
     }
     
@@ -202,13 +210,14 @@ public class query extends CmdARQ
             
             if ( isQuiet() )
                 LogCtl.setError(SysRIOT.riotLoggerName) ;
-            Dataset dataset = getDataset() ;
-            // Check there is a dataset
+            Dataset dataset = getDataset(query) ;
+            // Check there is a dataset. See dealWithNoDataset(query).
+            // The default policy is to create an empty one - convenience for VALUES and
BIND providing the data.
             if ( dataset == null && !query.hasDatasetDescription() ) {
                 System.err.println("Dataset not specified in query nor provided on command
line.");
                 throw new TerminationException(1);
             }
-            Transactional transactional = (dataset.supportsTransactionAbort()) ? dataset
: new TransactionalNull() ;
+            Transactional transactional = (dataset != null && dataset.supportsTransactionAbort())
? dataset : new TransactionalNull() ;
             Txn.executeRead(transactional, ()->{
                 modTime.startTimer() ;
                 try ( QueryExecution qe = QueryExecutionFactory.create(query, dataset) )
{


Mime
View raw message