You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2018/04/13 21:11:50 UTC

[01/10] jena git commit: JENA-1520: tdb2.tdbstats: cmd and fix for rdf:type

Repository: jena
Updated Branches:
  refs/heads/master db818ea3f -> bea349587


JENA-1520: tdb2.tdbstats: cmd and fix for rdf:type


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

Branch: refs/heads/master
Commit: 55516f717caba7d41c4b78ca298f4c030cedcddf
Parents: d30b3c0
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Apr 12 17:18:29 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Apr 12 17:18:29 2018 +0100

----------------------------------------------------------------------
 apache-jena/bat/tdb2_tdbstats.bat               | 18 ++++
 apache-jena/bin/tdb2.tdbstats                   | 89 ++++++++++++++++++++
 apache-jena/cmd-maker                           |  1 +
 .../jena/tdb2/solver/stats/StatsCollector.java  | 18 ++--
 .../tdb2/solver/stats/StatsCollectorBase.java   | 36 ++++----
 .../tdb2/solver/stats/StatsCollectorNodeId.java | 48 +++++------
 6 files changed, 157 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/55516f71/apache-jena/bat/tdb2_tdbstats.bat
----------------------------------------------------------------------
diff --git a/apache-jena/bat/tdb2_tdbstats.bat b/apache-jena/bat/tdb2_tdbstats.bat
new file mode 100644
index 0000000..a1d7b07
--- /dev/null
+++ b/apache-jena/bat/tdb2_tdbstats.bat
@@ -0,0 +1,18 @@
+@echo off
+@rem Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+if "%JENAROOT%" == "" goto :rootNotSet
+set JENA_HOME=%JENAROOT%
+:rootNotSet
+
+if NOT "%JENA_HOME%" == "" goto :okHome
+echo JENA_HOME not set
+exit /B
+
+:okHome
+set JENA_CP=%JENA_HOME%\lib\*;
+set LOGGING=file:%JENA_HOME%/jena-log4j.properties
+
+@rem JVM_ARGS comes from the environment.
+java %JVM_ARGS% -Dlog4j.configuration="%LOGGING%" -cp "%JENA_CP%" tdb2.tdbstats %*
+exit /B

http://git-wip-us.apache.org/repos/asf/jena/blob/55516f71/apache-jena/bin/tdb2.tdbstats
----------------------------------------------------------------------
diff --git a/apache-jena/bin/tdb2.tdbstats b/apache-jena/bin/tdb2.tdbstats
new file mode 100644
index 0000000..36363b5
--- /dev/null
+++ b/apache-jena/bin/tdb2.tdbstats
@@ -0,0 +1,89 @@
+#!/bin/sh
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+resolveLink() {
+  local NAME=$1
+
+  if [ -L "$NAME" ]; then
+    case "$OSTYPE" in
+      darwin*|bsd*)
+        # BSD style readlink behaves differently to GNU readlink
+        # Have to manually follow links
+        while [ -L "$NAME" ]; do
+          NAME=$( cd $NAME && pwd -P ) ;
+        done
+        ;;
+      *)
+        # Assuming standard GNU readlink with -f for
+        # canonicalize and follow
+        NAME=$(readlink -f "$NAME")
+        ;;
+    esac
+  fi
+
+  echo "$NAME"
+}
+
+# If JENA_HOME is empty
+if [ -z "$JENA_HOME" ]; then
+  SCRIPT="$0"
+  # Catch common issue: script has been symlinked
+  if [ -L "$SCRIPT" ]; then
+    SCRIPT=$(resolveLink "$0")
+    # If link is relative
+    case "$SCRIPT" in
+      /*)
+        # Already absolute
+        ;;
+      *)
+        # Relative, make absolute
+        SCRIPT=$( dirname "$0" )/$SCRIPT
+        ;;
+    esac
+  fi
+
+  # Work out root from script location
+  JENA_HOME="$( cd "$( dirname "$SCRIPT" )/.." && pwd )"
+  export JENA_HOME
+fi
+
+# If JENA_HOME is a symbolic link need to resolve
+if [ -L "${JENA_HOME}" ]; then
+  JENA_HOME=$(resolveLink "$JENA_HOME")
+  # If link is relative
+  case "$JENA_HOME" in
+    /*)
+      # Already absolute
+      ;;
+    *)
+      # Relative, make absolute
+      JENA_HOME=$(dirname "$JENA_HOME")
+      ;;
+  esac
+  export JENA_HOME
+fi
+
+# ---- Setup
+# JVM_ARGS : don't set here but it can be set in the environment.
+# Expand JENA_HOME but literal *
+JENA_CP="$JENA_HOME"'/lib/*'
+SOCKS=
+LOGGING="${LOGGING:--Dlog4j.configuration=file:$JENA_HOME/jena-log4j.properties}"
+
+# Platform specific fixup
+# On CYGWIN convert path and end with a ';' 
+case "$(uname)" in
+   CYGWIN*) JENA_CP="$(cygpath -wp "$JENA_CP");";;
+esac
+
+# Respect TMPDIR or TMP (windows?) if present
+# important for tdbloader spill
+if [ -n "$TMPDIR" ]
+	then
+	JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMPDIR\""
+elif [ -n "$TMP" ]
+	then
+	JVM_ARGS="$JVM_ARGS -Djava.io.tmpdir=\"$TMP\""
+fi
+
+java $JVM_ARGS $LOGGING -cp "$JENA_CP" tdb2.tdbstats "$@" 

http://git-wip-us.apache.org/repos/asf/jena/blob/55516f71/apache-jena/cmd-maker
----------------------------------------------------------------------
diff --git a/apache-jena/cmd-maker b/apache-jena/cmd-maker
index 2ce27b6..58e8040 100755
--- a/apache-jena/cmd-maker
+++ b/apache-jena/cmd-maker
@@ -67,6 +67,7 @@ tdb2.tdbdump
 tdb2.tdbcompact
 tdb2.tdbloader
 tdb2.tdbquery
+tdb2.tdbstats
 tdb2.tdbupdate
 EOF
 )

http://git-wip-us.apache.org/repos/asf/jena/blob/55516f71/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollector.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollector.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollector.java
index a751bb8..7176ee8 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollector.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollector.java
@@ -18,19 +18,19 @@
 
 package org.apache.jena.tdb2.solver.stats;
 
-import java.util.Map ;
+import java.util.Map;
 
-import org.apache.jena.graph.Node ;
-import org.apache.jena.sparql.graph.NodeConst ;
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.graph.NodeConst;
 
 /** Statistics collector, general purpose, uses Nodes */
-public class StatsCollector extends StatsCollectorBase<Node>
-{
-    public StatsCollector() { super(NodeConst.nodeRDFType) ; }
+public class StatsCollector extends StatsCollectorBase<Node> {
+    public StatsCollector() {
+        super(NodeConst.nodeRDFType);
+    }
 
     @Override
-    protected Map<Node, Integer> convert(Map<Node, Integer> map)
-    {
-        return map ;
+    protected Map<Node, Integer> convert(Map<Node, Integer> map) {
+        return map;
     }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/55516f71/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorBase.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorBase.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorBase.java
index 3de508e..871dcc6 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorBase.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorBase.java
@@ -25,30 +25,26 @@ import java.util.Map ;
 import org.apache.jena.graph.Node ;
 
 /** Statistics collector, general purpose */
-abstract class StatsCollectorBase<T>
-{
-    private long count = 0 ;
-    private Map<T, Integer> predicates = new HashMap<>(10000) ;
-    private Map<T, Integer> types = new HashMap<>(10000) ;
-    private T typeTrigger ;
-    
-    protected StatsCollectorBase(T typeTrigger)
-    {
-        this.typeTrigger = typeTrigger ;
+abstract class StatsCollectorBase<T> {
+    private long            count      = 0;
+    private Map<T, Integer> predicates = new HashMap<>(10000);
+    private Map<T, Integer> types      = new HashMap<>(10000);
+    private T               typeTrigger;
+
+    protected StatsCollectorBase(T typeTrigger) {
+        this.typeTrigger = typeTrigger;
     }
 
-    public void record(T g, T s, T p, T o)
-    {
-        count++ ;
-		predicates.put(p, predicates.getOrDefault(p, 0) + 1);
+    public void record(T g, T s, T p, T o) {
+        count++;
+        predicates.put(p, predicates.getOrDefault(p, 0) + 1);
         if ( typeTrigger != null && typeTrigger.equals(p) )
-        		types.put(o, types.getOrDefault(o, 0) + 1);
+            types.put(o, types.getOrDefault(o, 0) + 1);
     }
 
-    protected abstract Map<Node, Integer> convert(Map<T, Integer> map) ;
-    
-    public StatsResults results()
-    {
-        return new StatsResults(convert(predicates), convert(types), count) ;
+    protected abstract Map<Node, Integer> convert(Map<T, Integer> map);
+
+    public StatsResults results() {
+        return new StatsResults(convert(predicates), convert(types), count);
     }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/55516f71/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorNodeId.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorNodeId.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorNodeId.java
index c4b1b9c..ad61b91 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorNodeId.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorNodeId.java
@@ -18,39 +18,39 @@
 
 package org.apache.jena.tdb2.solver.stats;
 
-import java.util.HashMap ;
-import java.util.Map ;
+import java.util.HashMap;
+import java.util.Map;
 
-import org.apache.jena.graph.Node ;
-import org.apache.jena.sparql.graph.NodeConst ;
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.graph.NodeConst;
 import org.apache.jena.tdb2.store.NodeId;
 import org.apache.jena.tdb2.store.nodetable.NodeTable;
 
 /** Statistics collector, aggregates based on NodeId */
-public class StatsCollectorNodeId extends StatsCollectorBase<NodeId>
-{
-    private NodeTable nodeTable ;
-    
-    public StatsCollectorNodeId(NodeTable nodeTable)
-    {
-        super(findRDFType(nodeTable)) ;
-        this.nodeTable = nodeTable ;
+public class StatsCollectorNodeId extends StatsCollectorBase<NodeId> {
+    private NodeTable nodeTable;
+
+    public StatsCollectorNodeId(NodeTable nodeTable) {
+        super(findRDFType(nodeTable));
+        this.nodeTable = nodeTable;
     }
-    
-    private static NodeId findRDFType(NodeTable nodeTable2)
-    {
-        return nodeTable2.getAllocateNodeId(NodeConst.nodeRDFType) ;
+
+    private static NodeId findRDFType(NodeTable nodeTable) {
+        // It may not exist.
+        NodeId nodeId = nodeTable.getNodeIdForNode(NodeConst.nodeRDFType);
+        if ( NodeId.isDoesNotExist(nodeId) )
+            return null;
+        return nodeId;
     }
 
     @Override
-    protected Map<Node, Integer> convert(Map<NodeId, Integer> stats)
-    {
-        Map<Node, Integer> statsNodes = new HashMap<>(1000) ;
-        for ( NodeId p : stats.keySet() )
-        {
-            Node n = nodeTable.getNodeForNodeId(p) ;
-            statsNodes.put(n, stats.get(p)) ;
+    protected Map<Node, Integer> convert(Map<NodeId, Integer> stats) {
+        // Predicate -> Count
+        Map<Node, Integer> statsNodes = new HashMap<>(1000);
+        for ( NodeId p : stats.keySet() ) {
+            Node n = nodeTable.getNodeForNodeId(p);
+            statsNodes.put(n, stats.get(p));
         }
-        return statsNodes ;
+        return statsNodes;
     }
 }


[03/10] jena git commit: JENA-1521: Don't close. TDB1 and TDB2 datasets are managed differently.

Posted by an...@apache.org.
JENA-1521: Don't close. TDB1 and TDB2 datasets are managed differently.

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

Branch: refs/heads/master
Commit: f6d3c77f32e5ba8c48d2b987dea3915004970eab
Parents: 32608d2
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 13 14:04:55 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 13 14:04:55 2018 +0100

----------------------------------------------------------------------
 .../jena/tdb2/store/DatasetGraphSwitchable.java | 10 +++++
 .../transaction/DatasetGraphTransaction.java    | 40 ++++++++++----------
 2 files changed, 30 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/f6d3c77f/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/DatasetGraphSwitchable.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/DatasetGraphSwitchable.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/DatasetGraphSwitchable.java
index 60b654a..f27718c 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/DatasetGraphSwitchable.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/DatasetGraphSwitchable.java
@@ -81,6 +81,16 @@ public class DatasetGraphSwitchable extends DatasetGraphWrapper
         return dsgx.getAndSet(dsg);
     }
     
+    /** Don't do anythine on close.
+     *  This would not be safe across switches.  
+     */
+    @Override
+    public void close() {}
+    
+//    /** Don't do anything on sync. */
+//    @Override
+//    public void sync() { }
+    
     /** If and only if the current value is the given old value, set the base {@link DatasetGraph}  
      * Returns true if a swap happened.
      */ 

http://git-wip-us.apache.org/repos/asf/jena/blob/f6d3c77f/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
index bd5ba8b..fbb851b 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
@@ -290,32 +290,32 @@ import org.apache.jena.tdb.store.GraphTxnTDB ;
     protected void _close() {
         if ( isClosed )
             return ;
+        isClosed = true ;
         
-        if ( !sConn.haveUsedInTransaction() ) {
-            synchronized(this) {
-                if ( isClosed ) return ;
-                isClosed = true ;
-                if ( ! sConn.isValid() ) {
-                    // There may be another DatasetGraphTransaction using this location
-                    // and that DatasetGraphTransaction has been closed, invalidating
-                    // the StoreConnection.
-                    return ;
-                }
-                DatasetGraphTDB dsg = sConn.getBaseDataset() ;
-                dsg.sync() ;
-                dsg.close() ;
-                StoreConnection.release(getLocation()) ;
+        if ( sConn.haveUsedInTransaction() ) {
+            if ( isInTransaction() ) {
+                TDB.logInfo.warn("Attempt to close a DatasetGraphTransaction while a transaction is active - ignored close (" + getLocation() + ")") ;
                 return ;
             }
+            // Otherwise ignore - there might be other transactions aronud.
+            return ;
         }
-
-        if ( isInTransaction() ) {
-            TDB.logInfo.warn("Attempt to close a DatasetGraphTransaction while a transaction is active - ignored close (" + getLocation() + ")") ;
+        synchronized(this) {
+            if ( ! sConn.isValid() ) {
+                // There may be another DatasetGraphTransaction using this location
+                // and that DatasetGraphTransaction has been closed, invalidating
+                // the StoreConnection.
+                return ;
+            }
+            DatasetGraphTDB dsg = sConn.getBaseDataset() ;
+            dsg.sync() ;
+            dsg.close() ;
+            StoreConnection.release(getLocation()) ;
+            dsgtxn.remove() ;
+            inTransaction.remove() ;
+            isClosed = true ;
             return ;
         }
-        dsgtxn.remove() ;
-        inTransaction.remove() ;
-        isClosed = true ;
     }
 
     @Override


[09/10] jena git commit: JENA-1521: Merge commit 'refs/pull/397/head' of https://github.com/apache/jena

Posted by an...@apache.org.
JENA-1521: Merge commit 'refs/pull/397/head' of https://github.com/apache/jena

This closes #397.


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

Branch: refs/heads/master
Commit: 2341f3f8b1b4b59bc1934564e781de99e51c42e6
Parents: 6b6a01b d65e0ae
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 13 22:06:45 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 13 22:06:45 2018 +0100

----------------------------------------------------------------------
 .gitignore                                      |   3 -
 .../jena/sparql/core/DatasetGraphWithLock.java  | 186 -------------------
 .../java/org/apache/jena/tdb2/DatabaseMgr.java  |   4 -
 .../java/org/apache/jena/tdb2/TDB2Factory.java  |  49 ++---
 .../jena/tdb2/store/DatasetGraphSwitchable.java |  10 +
 .../jena/tdb2/sys/DatabaseConnection.java       |   3 +
 .../transaction/DatasetGraphTransaction.java    |  40 ++--
 7 files changed, 44 insertions(+), 251 deletions(-)
----------------------------------------------------------------------



[10/10] jena git commit: JENA-1523: Merge commit 'refs/pull/398/head' of https://github.com/apache/jena

Posted by an...@apache.org.
JENA-1523: Merge commit 'refs/pull/398/head' of https://github.com/apache/jena

Ths closes #398.


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

Branch: refs/heads/master
Commit: bea3495877820e2ba55f258e1752dd3c353e3412
Parents: 2341f3f 991ec09
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 13 22:07:15 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 13 22:07:15 2018 +0100

----------------------------------------------------------------------
 .../org/apache/jena/riot/tokens/TokenizerText.java   | 11 ++++++++---
 .../org/apache/jena/riot/tokens/TestTokenizer.java   | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[06/10] jena git commit: Remove stray local/

Posted by an...@apache.org.
Remove stray local/


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

Branch: refs/heads/master
Commit: d65e0ae630911cf1665cbd354d928765d16491ce
Parents: 67b18af
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 13 14:43:53 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 13 14:43:53 2018 +0100

----------------------------------------------------------------------
 .gitignore | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/d65e0ae6/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index c448fbc..f23f5b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,9 +22,6 @@ buildNumber.properties
 *.iml
 .idea/
 
-# Local area 
-local/
-
 # Caches
 .scala_dependencies
 


[05/10] jena git commit: JENA-1521: Only really close if non-transactional

Posted by an...@apache.org.
JENA-1521: Only really close if non-transactional


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

Branch: refs/heads/master
Commit: 67b18af43f54814f66f63c13866556b4256e459c
Parents: 246786a
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 13 14:31:51 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 13 14:31:51 2018 +0100

----------------------------------------------------------------------
 .../org/apache/jena/tdb/transaction/DatasetGraphTransaction.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/67b18af4/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
index fbb851b..b90d8ec 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
@@ -290,14 +290,12 @@ import org.apache.jena.tdb.store.GraphTxnTDB ;
     protected void _close() {
         if ( isClosed )
             return ;
-        isClosed = true ;
-        
         if ( sConn.haveUsedInTransaction() ) {
             if ( isInTransaction() ) {
                 TDB.logInfo.warn("Attempt to close a DatasetGraphTransaction while a transaction is active - ignored close (" + getLocation() + ")") ;
                 return ;
             }
-            // Otherwise ignore - there might be other transactions aronud.
+            // Otherwise ignore - close() while transactional is meaningless.
             return ;
         }
         synchronized(this) {


[02/10] jena git commit: Add TDB2Factory.assembleDataset. Remove out of date comments.

Posted by an...@apache.org.
Add TDB2Factory.assembleDataset. Remove out of date comments.

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

Branch: refs/heads/master
Commit: 32608d250fa60788b53db71b79d904fb63dbdd88
Parents: d30b3c0
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 13 13:59:35 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 13 13:59:35 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/jena/tdb2/DatabaseMgr.java  |  4 --
 .../java/org/apache/jena/tdb2/TDB2Factory.java  | 49 +++++---------------
 .../jena/tdb2/sys/DatabaseConnection.java       |  3 ++
 3 files changed, 15 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/32608d25/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java
index e8e0091..52ca661 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/DatabaseMgr.java
@@ -37,8 +37,6 @@ public class DatabaseMgr {
     // All creation of DatasetGraph for TDB2 goes through this method.
     private static DatasetGraph DB_ConnectCreate(Location location) {
         return DatabaseConnection.connectCreate(location).getDatasetGraph();
-//        // One level.
-//        return StoreConnection.connectCreate(location).getDatasetGraph() ; 
     }
 
     /** Create or connect to a TDB2-backed dataset */
@@ -79,7 +77,6 @@ public class DatabaseMgr {
         return DatabaseOps.backup(dsg);
     }
 
-
     /** Create an in-memory TDB2-backed dataset (for testing) */
     public static DatasetGraph createDatasetGraph() {
         return connectDatasetGraph(Location.mem()) ;
@@ -110,5 +107,4 @@ public class DatabaseMgr {
             throw new TDBException("Not a TDB database (argument is neither a switchable nor direct TDB DatasetGraph)");
         return dsg;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/32608d25/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java
index 62952d0..02b6138 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/TDB2Factory.java
@@ -22,12 +22,17 @@ import org.apache.jena.dboe.base.file.Location;
 import org.apache.jena.query.Dataset ;
 import org.apache.jena.query.DatasetFactory ;
 import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.core.assembler.AssemblerUtils ;
+import org.apache.jena.system.JenaSystem;
+import org.apache.jena.tdb2.assembler.VocabTDB2 ;
 
 /**
  *  Public factory for connecting to and creating datasets backed by TDB2 storage.
  */
 public class TDB2Factory
 {
+    static { JenaSystem.init(); }
+    
     private TDB2Factory() {} 
 
     /** @deprecated Use {@link DatabaseMgr#connectDatasetGraph(Location)} */
@@ -74,23 +79,13 @@ public class TDB2Factory
      */ 
     public static Dataset createDataset() { return connectDataset(Location.mem()) ; }
 
-//    /**
-//     *  Read the file and assembler a dataset
-//     */
-//    public static Dataset assembleDataset(String assemblerFile) {
-//        return (Dataset)AssemblerUtils.build(assemblerFile, VocabTDB.tDatasetTDB) ;
-//    }
-//    
-//    /** Release from the JVM. All caching is lost. */
-//    public static void release(Dataset dataset) {
-//        _release(location(dataset)) ;
-//    }
-//    
-//    /** Release from the JVM.  All caching is lost. */
-//    public static void release(DatasetGraph dataset) {
-//        _release(location(dataset)) ;
-//    }
-
+    /**
+     *  Read the file and assemble a dataset
+     */
+    public static Dataset assembleDataset(String assemblerFile) {
+        return (Dataset)AssemblerUtils.build(assemblerFile, VocabTDB2.tDatasetTDB) ;
+    }
+    
     /** Test whether a dataset is backed by TDB or not. */ 
     public static boolean isBackedByTDB(Dataset dataset) {
         DatasetGraph dsg = dataset.asDatasetGraph() ;
@@ -102,24 +97,4 @@ public class TDB2Factory
         DatasetGraph dsg = dataset.asDatasetGraph() ;
         return DatabaseMgr.location(dsg) ;
     }
-
-//    /** Set the {@link StoreParams} for specific Location.
-//     *  This call must only be called before a dataset from Location
-//     *  is created. This operation should be used with care; bad choices
-//     *  of {@link StoreParams} can reduce performance.
-//     *  
-//     *  <a href="http://jena.apache.org/documentation/tdb/store-paramters.html"
-//     *  >See documentation</a>.
-//     *  
-//     *  @param location  The persistent storage location
-//     *  @param params  StoreParams to use
-//     *  @throws IllegalStateException If the dataset has already been setup.
-//     */
-//    public static void setup(Location location, StoreParams params) {
-//        StoreConnection sConn = StoreConnection.getExisting(location) ;
-//        if ( sConn != null )
-//            throw new IllegalStateException("Location is already active") ;
-//        StoreConnection.make(location, params) ;
-//    }
-    
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/32608d25/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java
index 69d1499..4e94a9b 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/sys/DatabaseConnection.java
@@ -32,6 +32,7 @@ import org.apache.jena.dboe.base.file.Location;
 import org.apache.jena.dboe.base.file.ProcessFileLock;
 import org.apache.jena.dboe.sys.Names;
 import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.system.JenaSystem;
 import org.apache.jena.tdb2.TDBException;
 import org.apache.jena.tdb2.setup.StoreParams;
 import org.apache.jena.tdb2.store.DatasetGraphSwitchable;
@@ -39,6 +40,8 @@ import org.apache.jena.tdb2.store.DatasetGraphSwitchable;
 // StoreConnection, DatabaseConnection < Connection<X> 
 
 public class DatabaseConnection {
+    static { JenaSystem.init(); }
+
     // ConnectionTracker<X> 
     
     private static Map<Location, DatabaseConnection> cache = new ConcurrentHashMap<>() ;


[08/10] jena git commit: JENA-1520: Merge commit 'refs/pull/396/head' of https://github.com/apache/jena

Posted by an...@apache.org.
JENA-1520: Merge commit 'refs/pull/396/head' of https://github.com/apache/jena

This closes #396.


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

Branch: refs/heads/master
Commit: 6b6a01b7a2cbc429f968a2cd457c60f9d39e6dad
Parents: db818ea 55516f7
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 13 22:06:09 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 13 22:06:09 2018 +0100

----------------------------------------------------------------------
 apache-jena/bat/tdb2_tdbstats.bat               | 18 ++++
 apache-jena/bin/tdb2.tdbstats                   | 89 ++++++++++++++++++++
 apache-jena/cmd-maker                           |  1 +
 .../jena/tdb2/solver/stats/StatsCollector.java  | 18 ++--
 .../tdb2/solver/stats/StatsCollectorBase.java   | 36 ++++----
 .../tdb2/solver/stats/StatsCollectorNodeId.java | 48 +++++------
 6 files changed, 157 insertions(+), 53 deletions(-)
----------------------------------------------------------------------



[04/10] jena git commit: Remove deprecated DatasetGraphWithLock.

Posted by an...@apache.org.
Remove deprecated DatasetGraphWithLock.

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

Branch: refs/heads/master
Commit: 246786abfb60f2908bce52772cd40771ba2a206d
Parents: f6d3c77
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 13 14:05:16 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 13 14:05:16 2018 +0100

----------------------------------------------------------------------
 .../jena/sparql/core/DatasetGraphWithLock.java  | 186 -------------------
 1 file changed, 186 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/246786ab/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWithLock.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWithLock.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWithLock.java
deleted file mode 100644
index ff173b0..0000000
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphWithLock.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.sparql.core ;
-
-import org.apache.jena.atlas.lib.Lib ;
-import org.apache.jena.atlas.lib.Sync ;
-import org.apache.jena.query.ReadWrite ;
-import org.apache.jena.query.TxnType;
-import org.apache.jena.sparql.JenaTransactionException ;
-import org.apache.jena.sparql.SystemARQ ;
-import org.apache.jena.sparql.util.Context ;
-
-/**
- * A DatasetGraph that uses the dataset lock to give weak transactional
- * behaviour, that is the application see transaction but they are not durable.
- * Only provides multiple-reader OR single-writer, and no write-transaction
- * abort.
- * @deprecated Will be removed.
- */
-// NOT USED
-@Deprecated
-public class DatasetGraphWithLock extends DatasetGraphTrackActive implements Sync {
-    private final ThreadLocal<Boolean> writeTxn = ThreadLocal.withInitial(()->false) ;
-    private final DatasetGraph dsg ;
-    private final TransactionalLock transactional ;  
-    // Associated DatasetChanges (if any, may be null)
-    private final DatasetChanges dsChanges ;
-    private final boolean abortSupported ;
-
-    public DatasetGraphWithLock(DatasetGraph dsg) {
-        this(dsg, false) ;
-    }
-    
-    public DatasetGraphWithLock(DatasetGraph dsg, boolean abortSupported) {
-        this.dsg = dsg ;
-        this.dsChanges = findDatasetChanges(dsg) ;
-        this.transactional = TransactionalLock.create(dsg.getLock()) ;
-        this.abortSupported = abortSupported ;
-    }
-    
-    /** Find a DatasetChanges handler.
-     *  Unwrap layers of DatasetGraphWrapper to
-     *  look for a DatasetGraphMonitor.
-     */
-    private static DatasetChanges findDatasetChanges(DatasetGraph dataset) {
-        for(;;) {
-            // DatasetGraphMonitor extends DatasetGraphWrapper
-            if ( dataset instanceof DatasetGraphMonitor )
-                return ((DatasetGraphMonitor)dataset).getMonitor() ;
-            if ( ! ( dataset instanceof DatasetGraphWrapper ) )
-                return null ;
-            dataset = ((DatasetGraphWrapper)dataset).getWrapped() ;
-        }
-    }
-
-    @Override
-    protected DatasetGraph get() {
-        return dsg ;
-    }
-
-    @Override
-    protected void checkActive() {
-        if ( !isInTransaction() )
-            throw new JenaTransactionException("Not in a transaction") ;
-    }
-
-    @Override
-    protected void checkNotActive() {
-        if ( isInTransaction() )
-            throw new JenaTransactionException("Currently in a transaction") ;
-    }
-
-    @Override
-    public boolean isInTransaction() {
-        return transactional.isInTransaction() ;
-    }
-
-    protected boolean isTransactionMode(ReadWrite readWriteMode) {
-        return transactional.isTransactionMode(readWriteMode) ;
-    }
-    
-    /** @deprecated Use {@link #isTransactionMode} */
-    @Deprecated
-    protected boolean isTransactionType(ReadWrite readWriteMode) {
-        return transactional.isTransactionMode(readWriteMode) ;
-    }
-
-    @Override
-    protected void _begin(TxnType txnType) {
-        ReadWrite readWrite = TxnType.convert(txnType);
-        transactional.begin(txnType);
-        writeTxn.set(readWrite.equals(ReadWrite.WRITE));
-        if ( dsChanges != null )
-            // Replace by transactional state.
-            dsChanges.start() ;
-    }
-
-    @Override
-    protected boolean _promote(Promote promoteMode) {
-        throw new JenaTransactionException("promote not supported");
-    }
-
-    @Override
-    protected void _commit() {
-        if ( writeTxn.get() ) {
-            sync() ;
-        }
-        transactional.commit();
-        _end() ;
-    }
-
-    @Override
-    protected void _abort() {
-        if ( writeTxn.get() && ! supportsTransactionAbort() ) {
-            // Still clean up.
-            _end() ; // This clears the transaction type.  
-            throw new JenaTransactionException("Can't abort a write lock-transaction") ;
-        }
-        transactional.abort(); 
-        _end() ;
-    }
-
-    /** Return whether abort is provided.
-     *  Just by locking, a transaction can not write-abort (the changes have been made and not recorded).
-     *  Subclasses may do better and still rely on this locking class.  
-     */
-    
-    @Override
-    public boolean supportsTransactions() {
-        return true;
-    }
-
-    @Override
-    public boolean supportsTransactionAbort() {
-        return abortSupported;
-    }
-    
-    @Override
-    protected void _end() {
-        if ( dsChanges != null )
-            dsChanges.finish();
-        transactional.end(); 
-        writeTxn.remove();
-    }
-
-    @Override
-    protected void _close() {
-        if ( get() != null )
-            get().close() ;
-    }
-    
-    @Override
-    public Context getContext() {
-        return get().getContext() ;
-    }
-
-    @Override
-    public void sync() {
-        SystemARQ.sync(get()) ;
-    }
-
-    @Override
-    public String toString() {
-        try {
-            return get().toString() ;
-        } catch (Exception ex) {
-            return Lib.className(this) ;
-        }
-    }
-}


[07/10] jena git commit: JENA-1523: Allow internal variables names in variable parsing.

Posted by an...@apache.org.
JENA-1523: Allow internal variables names in variable parsing.


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

Branch: refs/heads/master
Commit: 991ec09cb1ac24c4c3b3e9d440b426045d2207be
Parents: db818ea
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Apr 13 17:53:48 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Apr 13 18:21:59 2018 +0100

----------------------------------------------------------------------
 .../org/apache/jena/riot/tokens/TokenizerText.java   | 11 ++++++++---
 .../org/apache/jena/riot/tokens/TestTokenizer.java   | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/991ec09c/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java b/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java
index d3cd80c..9f92fe9 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java
@@ -739,7 +739,13 @@ public final class TokenizerText implements Tokenizer
         return readCharsAnd(leadingDigitAllowed, leadingSignAllowed, extraCharsWord, false);
     }
 
-    static private char[] extraCharsVar = new char[]{'_', '.', '-', '?', '@', '+'};
+    // This array adds the other characters that can occurs in an internal variable name.
+    // Variables can be created with SPARQL-illegal syntax to ensure they do not clash with
+    // variables in the query from the application.
+    // See ARQConstants.
+    //   allocVarAnonMarker, allocVarMarker, globalVar, allocVarBNodeToVar, allocVarScopeHiding
+    // but this set is wider and matches anywhere in the name after the first '?'. 
+    static private char[] extraCharsVar = new char[]{'_', '.', '-', '?', '@', '+', '/', '~'};
 
     private String readVarName() {
         return readCharsAnd(true, true, extraCharsVar, true);
@@ -747,8 +753,7 @@ public final class TokenizerText implements Tokenizer
     
     // See also readBlankNodeLabel
     
-    private String readCharsAnd(boolean leadingDigitAllowed, boolean leadingSignAllowed, char[] extraChars,
-                                boolean allowFinalDot) {
+    private String readCharsAnd(boolean leadingDigitAllowed, boolean leadingSignAllowed, char[] extraChars, boolean allowFinalDot) {
         stringBuilder.setLength(0);
         int idx = 0;
         if ( !leadingDigitAllowed ) {

http://git-wip-us.apache.org/repos/asf/jena/blob/991ec09c/jena-arq/src/test/java/org/apache/jena/riot/tokens/TestTokenizer.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/riot/tokens/TestTokenizer.java b/jena-arq/src/test/java/org/apache/jena/riot/tokens/TestTokenizer.java
index 4baf1f2..f7ae2d1 100644
--- a/jena-arq/src/test/java/org/apache/jena/riot/tokens/TestTokenizer.java
+++ b/jena-arq/src/test/java/org/apache/jena/riot/tokens/TestTokenizer.java
@@ -655,6 +655,21 @@ public class TestTokenizer extends BaseTest {
     }
 
     @Test
+    public void tokenUnit_var7() {
+        tokenizeAndTestExact("?" + ARQConstants.allocVarScopeHiding + "0", TokenType.VAR, ARQConstants.allocVarScopeHiding + "0") ;
+    }
+
+    @Test
+    public void tokenUnit_var8() {
+        tokenizeAndTestExact("?" + ARQConstants.allocVarAnonMarker + "0", TokenType.VAR, ARQConstants.allocVarAnonMarker + "0") ;
+    }
+
+    @Test
+    public void tokenUnit_var9() {
+        tokenizeAndTestExact("?" + ARQConstants.allocVarBNodeToVar + "ABC", TokenType.VAR, ARQConstants.allocVarBNodeToVar + "ABC") ;
+    }
+
+    @Test
     public void tokenUnit_hex1() {
         tokenizeAndTestExact("0xABC", TokenType.HEX, "0xABC") ;
     }