jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1608034 - in /jena/site/trunk/content/documentation: notes/ query/ sdb/ tdb/
Date Sat, 05 Jul 2014 15:25:49 GMT
Author: andy
Date: Sat Jul  5 15:25:48 2014
New Revision: 1608034

URL: http://svn.apache.org/r1608034
Log:
JENA-728 : Update for try-resources on QueryExecution

Modified:
    jena/site/trunk/content/documentation/notes/concurrency-howto.mdtext
    jena/site/trunk/content/documentation/query/app_api.mdtext
    jena/site/trunk/content/documentation/query/explain.mdtext
    jena/site/trunk/content/documentation/query/extension.mdtext
    jena/site/trunk/content/documentation/query/http-auth.mdtext
    jena/site/trunk/content/documentation/query/logging.mdtext
    jena/site/trunk/content/documentation/sdb/javaapi.mdtext
    jena/site/trunk/content/documentation/tdb/configuration.mdtext
    jena/site/trunk/content/documentation/tdb/datasets.mdtext
    jena/site/trunk/content/documentation/tdb/optimizer.mdtext
    jena/site/trunk/content/documentation/tdb/quadfilter.mdtext
    jena/site/trunk/content/documentation/tdb/tdb_transactions.mdtext

Modified: jena/site/trunk/content/documentation/notes/concurrency-howto.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/notes/concurrency-howto.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/notes/concurrency-howto.mdtext (original)
+++ jena/site/trunk/content/documentation/notes/concurrency-howto.mdtext Sat Jul  5 15:25:48
2014
@@ -81,15 +81,14 @@ Outline:
       Query query = QueryFactory.create(queryString) ;
       model.enterCriticalSection(Lock.READ) ;
       try {
-        QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
-        ResultSet results = qexec.execSelect() ;
-       try {
-          for ( ; results.hasNext() ; )
-          {
-              QuerySolution soln = results.nextSolution() ;
-              RDFNode x = soln.get("..var name..") ;
-          }
-        } finally { qexec.close() ; }
+        try(QueryExecution qexec = QueryExecutionFactory.create(query, model)) {
+            ResultSet results = qexec.execSelect() ;
+            for ( ; results.hasNext() ; )
+            {
+                QuerySolution soln = results.nextSolution() ;
+                RDFNode x = soln.get("..var name..") ;
+            }
+        }
       } finally { model.leaveCriticalSection() ; }
 
 Updates to the model should not be performed inside the read-only

Modified: jena/site/trunk/content/documentation/query/app_api.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/query/app_api.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/query/app_api.mdtext (original)
+++ jena/site/trunk/content/documentation/query/app_api.mdtext Sat Jul  5 15:25:48 2014
@@ -42,7 +42,7 @@ query execution is closed.
       Model model = ... ;
       String queryString = " .... " ;
       Query query = QueryFactory.create(queryString) ;
-      try (QueryExecution qexec = QueryExecutionFactory.create(query, model) )
+      try (QueryExecution qexec = QueryExecutionFactory.create(query, model))
         ResultSet results = qexec.execSelect() ;
         for ( ; results.hasNext() ; )
         {
@@ -194,9 +194,9 @@ more named graphs. Datasets can be const
     Query query = QueryFactory.create(queryString) ;
 
     Dataset dataset = DatasetFactory.create(dftGraphURI, namedGraphURIs) ;
-    QueryExecution qExec = QueryExecutionFactory.create(query, dataset) ;
-    try { ... }
-    finally { qExec.close() ; }
+    try(QueryExecution qExec = QueryExecutionFactory.create(query, dataset)) {
+        ...
+    }
 
 Already existing models can also be used:
 
@@ -204,6 +204,8 @@ Already existing models can also be used
     dataset.setDefaultModel(model) ;
     dataset.addNamedModel("http://example/named-1", modelX) ;
     dataset.addNamedModel("http://example/named-2", modelY) ;
-    QueryExecution qExec = QueryExecutionFactory.create(query, dataset) ;
+     try(QueryExecution qExec = QueryExecutionFactory.create(query, dataset)) {
+        ...
+    }
 
 [ARQ documentation index](index.html)

Modified: jena/site/trunk/content/documentation/query/explain.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/query/explain.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/query/explain.mdtext (original)
+++ jena/site/trunk/content/documentation/query/explain.mdtext Sat Jul  5 15:25:48 2014
@@ -76,8 +76,11 @@ globally:
 and it may also be set on an individual query execution using it's local
 context.
 
-     QueryExecutiuon qExec = QueryExecutionFactory.create(...) ;
-     qExec.getContext().set(ARQ.symLogExec, Explain.InfoLevel.ALL) ;
+     try(QueryExecutiuon qExec = QueryExecutionFactory.create(...)) {
+         qExec.getContext().set(ARQ.symLogExec, Explain.InfoLevel.ALL) ;
+         ResultSet rs = qExec.execSelect() ;
+         ...
+     }
 
 On the command line:
 

Modified: jena/site/trunk/content/documentation/query/extension.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/query/extension.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/query/extension.mdtext (original)
+++ jena/site/trunk/content/documentation/query/extension.mdtext Sat Jul  5 15:25:48 2014
@@ -109,7 +109,10 @@ be turned off by the Java code:
 
 or on a per instance basis:
 
-     QueryExecution qExec = . . . ; qExec.getContext().setFalse(ARQ.enablePropertyFunctions)
;
+     try(QueryExecution qExec = ... ) {
+         qExec.getContext().setFalse(ARQ.enablePropertyFunctions) ;
+         ...
+     }
 
 The property functions in the ARQ distribution are described on the
 [property function library page](library-propfunc.html).

Modified: jena/site/trunk/content/documentation/query/http-auth.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/query/http-auth.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/query/http-auth.mdtext (original)
+++ jena/site/trunk/content/documentation/query/http-auth.mdtext Sat Jul  5 15:25:48 2014
@@ -35,7 +35,11 @@ From 2.11.0 onwards the relevant factory
 avoids the needs to cast and manually set the authenticator afterwards e.g.
 
     HttpAuthenticator authenticator = new SimpleAuthenticator("user", "password".toCharArray());
-    QueryExecution qe = QueryExecutionFactory.sparqlService("http://example.org/sparql",
"SELECT * WHERE { ?s a ?type }", authenticator);
+    try(QueryExecution qe = QueryExecutionFactory.sparqlService("http://example.org/sparql",
+                                                                "SELECT * WHERE { ?s a ?type
}", 
+                                                                authenticator)) {
+        ...
+    }
 
 ### Authenticators
 

Modified: jena/site/trunk/content/documentation/query/logging.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/query/logging.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/query/logging.mdtext (original)
+++ jena/site/trunk/content/documentation/query/logging.mdtext Sat Jul  5 15:25:48 2014
@@ -85,8 +85,10 @@ globally:
 and it may also be set on an individual query execution using its local
 context.
 
-     QueryExecutiuon qExec = QueryExecutionFactory.create(...) ;
-     qExec.getContext().set(ARQ.symLogExec, Explain.InfoLevel.ALL) ;
+     try(QueryExecutiuon qExec = QueryExecutionFactory.create(...)) {
+        qExec.getContext().set(ARQ.symLogExec, Explain.InfoLevel.ALL) ;
+        ...
+     }
 
 On the command line:
 

Modified: jena/site/trunk/content/documentation/sdb/javaapi.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/sdb/javaapi.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/sdb/javaapi.mdtext (original)
+++ jena/site/trunk/content/documentation/sdb/javaapi.mdtext Sat Jul  5 15:25:48 2014
@@ -159,11 +159,10 @@ container:
             Store store = SDBFactory.connectStore(conn, storeDesc) ;
 
             Dataset ds = SDBFactory.connectDataset(store) ;
-            QueryExecution qe = QueryExecutionFactory.create(query, ds) ;
-            try {
+            try(QueryExecution qe = QueryExecutionFactory.create(query, ds)) {
                 ResultSet rs = qe.execSelect() ;
                 ResultSetFormatter.out(rs) ;
-            } finally { qe.close() ; }
+            }
             store.close() ;
         }
 
@@ -206,11 +205,10 @@ dataset which is of the SDB class `Datas
 This is then used as normal with ARQ:
 
        Dataset ds = DatasetStore.create(store) ;
-       QueryExecution qe = QueryExecutionFactory.create(query, ds) ;
-       try {
+       try(QueryExecution qe = QueryExecutionFactory.create(query, ds)) {
            ResultSet rs = qe.execSelect() ;
            ResultSetFormatter.out(rs) ;
-       } finally { qe.close() ; }
+       }
 
 When finished, the store should be closed to release any resources
 associated with the particular implementation. Closing a store does

Modified: jena/site/trunk/content/documentation/tdb/configuration.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/tdb/configuration.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/tdb/configuration.mdtext (original)
+++ jena/site/trunk/content/documentation/tdb/configuration.mdtext Sat Jul  5 15:25:48 2014
@@ -37,8 +37,10 @@ Setting globally:
 
 Per query execution:
 
-     QueryExecution qExec = QueryExecutionFactory.create(...) ;
-     qExec.getContext().set(symbol, value) ;
+     try(QueryExecution qExec = QueryExecutionFactory.create(...)) {
+         qExec.getContext().set(symbol, value) ;
+         ...
+     }
 
 Setting for a query execution happens before any query compilation
 or setup happens. Creation of a query execution object does not

Modified: jena/site/trunk/content/documentation/tdb/datasets.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/tdb/datasets.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/tdb/datasets.mdtext (original)
+++ jena/site/trunk/content/documentation/tdb/datasets.mdtext Sat Jul  5 15:25:48 2014
@@ -46,8 +46,10 @@ Set globally:
 
 or set on a per query basis:
 
-    QueryExecution qExec = QueryExecutionFactory.create(...) ;
-    qExec.getContext().set(TDB.symUnionDefaultGraph, true) ;
+    try(QueryExecution qExec = QueryExecutionFactory.create(...)) {
+        qExec.getContext().set(TDB.symUnionDefaultGraph, true) ;
+        ...
+    }
 
 ## Special Graph Names
 

Modified: jena/site/trunk/content/documentation/tdb/optimizer.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/tdb/optimizer.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/tdb/optimizer.mdtext (original)
+++ jena/site/trunk/content/documentation/tdb/optimizer.mdtext Sat Jul  5 15:25:48 2014
@@ -108,8 +108,10 @@ set globally:
 and it may also be set on an individual query execution using it's
 local context.
 
-     QueryExecutiuon qExec = QueryExecutionFactory.create(...) ;
-     qExec.getContext().set(ARQ.symLogExec,true) ;
+     try(QueryExecutiuon qExec = QueryExecutionFactory.create(...)) {
+        qExec.getContext().set(ARQ.symLogExec,true) ;
+        ResultSet rs = qExec.execSelect() ;
+     }
 
 Use `TDB.symLogExec` for versions prior to 0.8.8.
 

Modified: jena/site/trunk/content/documentation/tdb/quadfilter.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/tdb/quadfilter.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/tdb/quadfilter.mdtext (original)
+++ jena/site/trunk/content/documentation/tdb/quadfilter.mdtext Sat Jul  5 15:25:48 2014
@@ -60,12 +60,13 @@ a immutable tuples of values of the same
       }
 
 To install a filter, put it in the context of a query execution
-under the symbol `SystemTDB.symTupleFilter`
+under the symbol `SystemTDB.symTupleFilter` then execute the query as normal.
 
         Dataset ds = ... ;
         Filter<Tuple<NodeId>> filter = createFilter(ds) ;
         Query query = ... ;
-        QueryExecution qExec = QueryExecutionFactory.create(query, ds) ;
-        qExec.getContext().set(SystemTDB.symTupleFilter, filter) ;
-
-then execute the query as normal.
+        try (QueryExecution qExec = QueryExecutionFactory.create(query, ds)) {
+            qExec.getContext().set(SystemTDB.symTupleFilter, filter) ;
+            ResultSet rs = qExec.execSelect() ;
+            ...
+        }

Modified: jena/site/trunk/content/documentation/tdb/tdb_transactions.mdtext
URL: http://svn.apache.org/viewvc/jena/site/trunk/content/documentation/tdb/tdb_transactions.mdtext?rev=1608034&r1=1608033&r2=1608034&view=diff
==============================================================================
--- jena/site/trunk/content/documentation/tdb/tdb_transactions.mdtext (original)
+++ jena/site/trunk/content/documentation/tdb/tdb_transactions.mdtext Sat Jul  5 15:25:48
2014
@@ -95,21 +95,18 @@ The `dataset.end()` declares the end of 
      Location location = ... ;
      Dataset dataset = ... ;
      dataset.begin(ReadWrite.READ) ;
-        
-     try {
-         QueryExecution qExec = QueryExecutionFactory.create("SELECT * {?s ?p ?o} LIMIT 10",
dataset) ;
+     String qs1 = "SELECT * {?s ?p ?o} LIMIT 10" ;        
+
+     try(QueryExecution qExec = QueryExecutionFactory.create(qs1, dataset)) {
          ResultSet rs = qExec.execSelect() ;
-         try {
-             ResultSetFormatter.out(rs) ;
-         } finally { qExec.close() ; }
+         ResultSetFormatter.out(rs) ;
+     } 
 
-         // Another query - same view of the data.
-         qExec = QueryExecutionFactory.create("SELECT * {?s ?p ?o} OFFSET 10 LIMIT 10", dataset)
;
+     String qs2 = "SELECT * {?s ?p ?o} OFFSET 10 LIMIT 10" ;  
+     try(QueryExecution qExec = QueryExecutionFactory.create(qs2, dataset)) {
          rs = qExec.execSelect() ;
-         try {
-             ResultSetFormatter.out(rs) ;
-         } finally { qExec.close() ; }
-     } finally { dataset.end() ; }
+         ResultSetFormatter.out(rs) ;
+     }
 
 ### Write transactions
 
@@ -145,13 +142,12 @@ dataset.
          model.add( ... )
 
          // A SPARQL query will see the new statement added.
-         QueryExecution qExec = QueryExecutionFactory.create(
-               "SELECT (count(*) AS ?count) { ?s ?p ?o} LIMIT 10", 
-               dataset) ;
-         ResultSet rs = qExec.execSelect() ;
-         try {
+         try (QueryExecution qExec = QueryExecutionFactory.create(
+                 "SELECT (count(*) AS ?count) { ?s ?p ?o} LIMIT 10", 
+               dataset)) {
+             ResultSet rs = qExec.execSelect() ;
              ResultSetFormatter.out(rs) ;
-         } finally { qExec.close() ; }
+         }
 
          // ... perform a SPARQL Update
          GraphStore graphStore = GraphStoreFactory.create(dataset) ;



Mime
View raw message