You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by aj...@apache.org on 2018/01/06 15:18:03 UTC

[39/44] jena git commit: Rebasing to use new transaction promotion machinery

Rebasing to use new transaction promotion machinery


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

Branch: refs/heads/master
Commit: 0515165cb57d3c203c104e9c04c1ff86ba87defc
Parents: 4e60b0f
Author: ajs6f <aj...@apache.org>
Authored: Fri Jan 5 10:19:04 2018 -0500
Committer: ajs6f <aj...@apache.org>
Committed: Fri Jan 5 10:19:04 2018 -0500

----------------------------------------------------------------------
 .../java/org/apache/jena/query/TxnType.java     |  4 +--
 .../apache/jena/sparql/core/Transactional.java  | 20 +++++++--------
 .../jena/sparql/util/DyadicDatasetGraph.java    | 26 ++++++++++++++++++++
 3 files changed, 38 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/0515165c/jena-arq/src/main/java/org/apache/jena/query/TxnType.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/query/TxnType.java b/jena-arq/src/main/java/org/apache/jena/query/TxnType.java
index a315a13..56c841a 100644
--- a/jena-arq/src/main/java/org/apache/jena/query/TxnType.java
+++ b/jena-arq/src/main/java/org/apache/jena/query/TxnType.java
@@ -36,11 +36,11 @@ public enum TxnType {
      * exception.
      * 
      * <li>{@code READ_COMMITTED_PROMOTE}: Use this with care. The promotion will succeed but 
-     * changes from oher transactions become visible.
+     * changes from other transactions become visible.
      * </ul>
      * 
      * Read committed: at the point transaction attempts promotion from "read" to
-     * "write", the sytem checks if the datset has chnage since the trsnaction started
+     * "write", the system checks if the dataset has changed since the transaction started
      * (called {@code begin}). If {@code READ_PROMOTE}, the dataset must not have
      * changed; if {@code READ_COMMITTED_PROMOTE} any intermediate changes are
      * visible but the application can not assume any data it has read in the

http://git-wip-us.apache.org/repos/asf/jena/blob/0515165c/jena-arq/src/main/java/org/apache/jena/sparql/core/Transactional.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/Transactional.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/Transactional.java
index 85f3b5d..271e287 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/Transactional.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/Transactional.java
@@ -63,21 +63,21 @@ public interface Transactional
 {
     /**
      * Start a transaction which is READ mode and which will switch to WRITE if an update
-     * is attempted but only if no intermdiate transaction has performed an update. 
+     * is attempted but only if no intermediate transaction has performed an update. 
      * <p>
      * See {@link #begin(TxnType)} for more details an options.
      * <p>
-     * May not be implemented. See {@link #begin(ReadWrite)} is guaranted to be provided.
+     * May not be implemented. See {@link #begin(ReadWrite)} is guaranteed to be provided.
      */
     public default void begin() { begin(TxnType.READ_PROMOTE); }
     
     /**
      * Start a transaction.<br/>
-     * READ or WRITE transactions start in that state and do not chnage for the
+     * READ or WRITE transactions start in that state and do not change for the
      * lifetime of the transaction.
      * <ul>
      * 
-     * <li>{@code WRITE}: this gaurantees a WRITE will complete if {@code commit()} is
+     * <li>{@code WRITE}: this guarantees a WRITE will complete if {@code commit()} is
      * called. The same as {@code begin(ReadWrite.WRITE)}.
      * 
      * <li>{@code READ}: the transaction can not promote to WRITE,ensuring read-only
@@ -88,14 +88,14 @@ public interface Transactional
      * transaction. See also {@link #promote}.
      * 
      * <li>{@code READ_COMMITTED_PROMOTE}: Use this with care. The promotion will
-     * succeed but changes from oher transactions become visible.
+     * succeed but changes from other transactions become visible.
      * 
      * </ul>
      * 
      * Read committed: at the point transaction attempts promotion from "read" to
-     * "write", the sytem checks if the datset has chnage since the trsnaction started
+     * "write", the system checks if the dataset has change since the transaction started
      * (called {@code begin}). If {@code READ_PROMOTE}, the dataset must not have
-     * changed; if {@code READ_COMMITTED_PROMOTE} anyh intermediate changes are
+     * changed; if {@code READ_COMMITTED_PROMOTE} any intermediate changes are
      * visible but the application can not assume any data it has read in the
      * transaction is the same as it was at the point the transaction started.
      * <p>
@@ -113,13 +113,13 @@ public interface Transactional
      * Attempt to promote a transaction from "read" to "write" and the transaction
      * start with a "promote" mode ({@code READ_PROMOTE} or {@code READ_COMMITTED_PROMOTE}).
      * <p>
-     * Returns "true" if the transction is in write mode after the call.
-     * The method always succeeeds of the transaction is already
+     * Returns "true" if the transaction is in write mode after the call.
+     * The method always succeeds of the transaction is already
      * "write".
      * <p>
      * This method returns true if a {@code READ_PROMOTE} or {@code READ_COMMITTED_PROMOTE} is promoted.
      * <p>
-     * This method returns false if a {@code READ_PROMOTE} can't be promoted - the transaction is stil valid and in "read" mode. 
+     * This method returns false if a {@code READ_PROMOTE} can't be promoted - the transaction is still valid and in "read" mode. 
      * <p>
      * This method throws an exception if there is an attempt to promote a "READ" transaction. 
      */

http://git-wip-us.apache.org/repos/asf/jena/blob/0515165c/jena-arq/src/main/java/org/apache/jena/sparql/util/DyadicDatasetGraph.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/DyadicDatasetGraph.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/DyadicDatasetGraph.java
index 25a9055..346ab5c 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/util/DyadicDatasetGraph.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/DyadicDatasetGraph.java
@@ -34,6 +34,7 @@ import org.apache.jena.graph.Graph;
 import org.apache.jena.graph.Node;
 import org.apache.jena.graph.compose.MultiUnion;
 import org.apache.jena.query.ReadWrite;
+import org.apache.jena.query.TxnType;
 import org.apache.jena.shared.Lock;
 import org.apache.jena.sparql.core.DatasetGraph;
 import org.apache.jena.sparql.core.Quad;
@@ -60,6 +61,31 @@ public abstract class DyadicDatasetGraph extends PairOfSameType<DatasetGraph> im
     }
 
     @Override
+    public void begin(TxnType type) {
+        switch (type) {
+        case WRITE:
+            throwNoMutationAllowed();
+        default:
+            forEach(dsg -> dsg.begin(type));
+        }
+    }
+
+    @Override
+    public boolean promote() {
+        return false;
+    }
+
+    @Override
+    public ReadWrite transactionMode() {
+        return apply((rw1, rw2) -> rw1 == rw2 ? rw1 : null, DatasetGraph::transactionMode);
+    }
+
+    @Override
+    public TxnType transactionType() {
+        return apply((t1, t2) -> t1 == t2 ? t1 : null, DatasetGraph::transactionType);
+    }
+
+    @Override
     public synchronized void begin(ReadWrite readWrite) {
         switch (readWrite) {
         case WRITE: