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 2021/03/20 16:15:29 UTC

[jena] branch main updated: JENA-2071: Deprecate DatasetChanges. Preserve jena-text.

This is an automated email from the ASF dual-hosted git repository.

andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git


The following commit(s) were added to refs/heads/main by this push:
     new af6de29  JENA-2071: Deprecate DatasetChanges. Preserve jena-text.
     new 541f4d8  Merge pull request #959 from afs/quad-changes
af6de29 is described below

commit af6de29805fdf8a4ef3fffc0270ba4bbae4453f5
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Tue Mar 16 19:44:34 2021 +0000

    JENA-2071: Deprecate DatasetChanges. Preserve jena-text.
---
 .../apache/jena/sparql/core/DatasetChanges.java    |  3 +
 .../jena/sparql/core/DatasetChangesBatched.java    |  2 +
 .../jena/sparql/core/DatasetChangesCapture.java    |  9 ++-
 .../jena/sparql/core/DatasetChangesCounter.java    | 19 +++--
 .../jena/sparql/core/DatasetGraphMonitor.java      | 59 +++++++-------
 .../org/apache/jena/sparql/core/QuadAction.java    | 11 +--
 .../java/org/apache/jena/sparql/core/TS_Core.java  |  1 -
 .../org/apache/jena/tdb2/store/StorageTDB.java     | 39 +---------
 .../apache/jena/query/text/DatasetGraphText.java   | 54 ++++++-------
 .../apache/jena/query/text/TextDocProducer.java    |  4 +-
 .../jena/query/text/TextDocProducerEntities.java   | 16 ++--
 .../jena/query/text/TextDocProducerTriples.java    | 16 ++--
 .../org/apache/jena/query/text/TextIndexTDB1.java  |  2 +-
 .../jena/query/text/changes/ChangesBatched.java    | 15 ++--
 .../text/changes/DatasetGraphTextMonitor.java      | 90 +++++++++++-----------
 .../query/text/changes/TextDatasetChanges.java     |  8 +-
 .../jena/query/text/changes/TextQuadAction.java    | 16 ++--
 .../java/org/apache/jena/query/text/TS_Text.java   |  8 +-
 .../text/assembler/TestTextDatasetAssembler.java   | 67 +---------------
 .../jena/query/text/changes/ChangesCapture.java    | 30 ++++----
 .../jena/query/text/changes/ChangesCounter.java    | 35 +++++----
 .../query/text/changes}/TestDatasetMonitor.java    | 79 ++++++++++---------
 22 files changed, 256 insertions(+), 327 deletions(-)

diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChanges.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChanges.java
index e667e6f..745b8c8 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChanges.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChanges.java
@@ -22,7 +22,10 @@ import org.apache.jena.graph.Node ;
 
 /** Interface for notification of changes
  * (adds and deletes of quads) to a DatasetGraph
+ * @deprecated Do not use. This interface will be removed or significantly changed.
+ *       To see changes to a dataset, use {@link DatasetGraphWrapper} to capture events of interest.
  */
+@Deprecated
 public interface DatasetChanges
 {
     /** Indicator that a sequence of changes is about to start */
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesBatched.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesBatched.java
index 7dcdff6..de0f68e 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesBatched.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesBatched.java
@@ -27,7 +27,9 @@ import org.apache.jena.graph.Node ;
 /**
  * Collect a stream of DatasetChanges into batches. A batch is adjacent quads
  * changes with (same graph, same subject, same action).
+ * @deprecated Do not use. This class does not have a clear contract when used with transactions.
  */
+@Deprecated
 public abstract class DatasetChangesBatched implements DatasetChanges {
     private QuadAction currentAction   = null ;
     private Node       currentSubject  = null ;
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCapture.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCapture.java
index 0c72ffd..3d90531 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCapture.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCapture.java
@@ -25,7 +25,10 @@ import java.util.List ;
 import org.apache.jena.atlas.lib.Pair ;
 import org.apache.jena.graph.Node ;
 
-/** Capture a record of quad actions */
+/** Capture a record of quad actions
+ * @deprecated Do not use. This class is not transaction-aware.
+ */
+@Deprecated
 public class DatasetChangesCapture implements DatasetChanges {
     // ArrayLists have an annoying issue that they grow by copying the internal
     // []-array.
@@ -47,7 +50,7 @@ public class DatasetChangesCapture implements DatasetChanges {
 
     /**
      * Capture quad actions, either including or excluding the "no ops"
-     * 
+     *
      * @param recordNoOps
      *            Whether to record {@link QuadAction#NO_ADD} and
      *            {@link QuadAction#NO_DELETE}
@@ -66,7 +69,7 @@ public class DatasetChangesCapture implements DatasetChanges {
     }
 
     /** The actions recorded.
-     *  Only valid until the next {@code start} call.   
+     *  Only valid until the next {@code start} call.
      */
     public List<Pair<QuadAction, Quad>> getActions() {
         return Collections.unmodifiableList(actions) ;
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCounter.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCounter.java
index 3a157e6..7cdc1f0 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCounter.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCounter.java
@@ -20,17 +20,20 @@ package org.apache.jena.sparql.core;
 
 import org.apache.jena.graph.Node ;
 
-/** Count changes, or simply note if a change has been made. */
+/** Count changes, or simply note if a change has been made.
+ *  @deprecated Do not use. This class is not transaction-aware.
+ */
+@Deprecated
 public class DatasetChangesCounter implements DatasetChanges
 {
     long countStart    = 0 ;
     long countFinish   = 0 ;
-    
+
     long countAdd      = 0 ;
     long countDelete   = 0 ;
     long countNoAdd    = 0 ;
     long countNoDelete = 0 ;
-    
+
     @Override
     public void start() {
         countStart++ ;
@@ -45,7 +48,7 @@ public class DatasetChangesCounter implements DatasetChanges
             case DELETE:    countDelete++ ; break ;
             case NO_ADD:    countNoAdd++ ; break ;
             case NO_DELETE: countNoDelete++ ; break ;
-            //default : break ;        
+            //default : break ;
         }
     }
 
@@ -53,16 +56,16 @@ public class DatasetChangesCounter implements DatasetChanges
     public void finish() {
         countFinish++ ;
     }
-    
+
     public boolean hasChanged() {
         return countAdd > 0 || countDelete > 0 ;
     }
-    
+
     @Override
-    public void reset() { 
+    public void reset() {
         countStart    = 0 ;
         countFinish   = 0 ;
-        
+
         countAdd      = 0 ;
         countDelete   = 0 ;
         countNoAdd    = 0 ;
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMonitor.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMonitor.java
index 8ae5509..3cdce55 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMonitor.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMonitor.java
@@ -34,16 +34,17 @@ import org.apache.jena.util.iterator.ExtendedIterator ;
 /** Connect a DatasetGraph to a DatasetChanges monitor.
  *  Any add or delete to the DatasetGraph is notified to the
  *  monitoring object with a {@link QuadAction} to indicate
- *  the change made.   
+ *  the change made.
+ *  @deprecated Do not use. This class does not reflect transactions.
  */
-
+@Deprecated
 public class DatasetGraphMonitor extends DatasetGraphWrapper
 {
-    /** Whether to see if a quad action will change the dataset - test before add for existence, test before delete for absence */   
+    /** Whether to see if a quad action will change the dataset - test before add for existence, test before delete for absence */
     private boolean CheckFirst = true ;
-    /** Whether to record a no-op (maybe as a comment) */   
+    /** Whether to record a no-op (maybe as a comment) */
     private boolean RecordNoAction = true ;
-    /** Where to send the notifications */  
+    /** Where to send the notifications */
     private final DatasetChanges monitor ;
 
     /**
@@ -52,11 +53,11 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
      * Note whether additions of deletions cause an actual change to the dataset or not.
      * @param dsg       The DatasetGraph to monitor
      * @param monitor   The handler for a change
-     *         
+     *
      * @see DatasetChanges
      * @see QuadAction
      */
-    public DatasetGraphMonitor(DatasetGraph dsg, DatasetChanges monitor) 
+    protected DatasetGraphMonitor(DatasetGraph dsg, DatasetChanges monitor)
     {
         super(dsg) ;
         this.monitor = monitor ;
@@ -64,26 +65,26 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
 
     /**
      * Create a DatasetGraph wrapper that monitors the dataset for changes (add or delete quads).
-     * Use this DatasetGraph for all operations in order to record changes.  
+     * Use this DatasetGraph for all operations in order to record changes.
      * @param dsg       The DatasetGraph to monitor
      * @param monitor   The handler for a change
      * @param recordOnlyIfRealChange
      *         If true, check to see if the change would have an effect (e.g. add is a new quad).
      *         If false, log changes as ADD/DELETE regardless of whether the dataset actually changes.
-     *         
+     *
      * @see DatasetChanges
      * @see QuadAction
      */
-    public DatasetGraphMonitor(DatasetGraph dsg, DatasetChanges monitor, boolean recordOnlyIfRealChange) 
+    protected DatasetGraphMonitor(DatasetGraph dsg, DatasetChanges monitor, boolean recordOnlyIfRealChange)
     {
         super(dsg) ;
         CheckFirst = recordOnlyIfRealChange ;
         this.monitor = monitor ;
     }
 
-    /** Return the monitor */ 
+    /** Return the monitor */
     public DatasetChanges getMonitor()      { return monitor ; }
-    
+
     /** Return the monitored DatasetGraph */
     public DatasetGraph   monitored()       { return getWrapped() ; }
 
@@ -97,25 +98,25 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
         }
         add$(quad) ;
     }
-    
+
     @Override public void add(Node g, Node s, Node p, Node o)
     {
         if ( CheckFirst && contains(g,s,p,o) )
         {
             if ( RecordNoAction )
-                record(QuadAction.NO_ADD,g,s,p,o) ; 
+                record(QuadAction.NO_ADD,g,s,p,o) ;
             return ;
         }
-        
+
         add$(g,s,p,o) ;
     }
-    
+
     private void add$(Node g, Node s, Node p, Node o)
     {
         super.add(g,s,p,o) ;
-        record(QuadAction.ADD,g,s,p,o) ; 
+        record(QuadAction.ADD,g,s,p,o) ;
     }
-    
+
     private void add$(Quad quad)
     {
         super.add(quad) ;
@@ -132,7 +133,7 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
         }
         delete$(quad) ;
     }
-    
+
     @Override public void delete(Node g, Node s, Node p, Node o)
     {
         if ( CheckFirst && ! contains(g,s,p,o) )
@@ -143,36 +144,36 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
         }
         delete$(g,s,p,o) ;
     }
-    
+
     private void delete$(Quad quad)
     {
         super.delete(quad) ;
         record(QuadAction.DELETE, quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
     }
-    
+
     private void delete$(Node g, Node s, Node p, Node o)
     {
         super.delete(g,s,p,o) ;
-        record(QuadAction.DELETE,g,s,p,o) ; 
+        record(QuadAction.DELETE,g,s,p,o) ;
     }
-    
+
 
     private static int SLICE = 1000 ;
-    
+
     @Override
     public void deleteAny(Node g, Node s, Node p, Node o)
     {
         while (true)
         {
             Iterator<Quad> iter = find(g, s, p, o) ;
-            // Materialize - stops possible ConcurrentModificationExceptions 
+            // Materialize - stops possible ConcurrentModificationExceptions
             List<Quad> some = take(iter, SLICE) ;
             for (Quad q : some)
                 delete$(q) ;
             if (some.size() < SLICE) break ;
         }
     }
-    
+
     @Override public void addGraph(Node gn, Graph g)
     {
         // Convert to quads.
@@ -184,18 +185,18 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
             add(gn, t.getSubject(), t.getPredicate(), t.getObject()) ;
         }
     }
-    
+
     @Override public void removeGraph(Node gn)
     {
         //super.removeGraph(gn) ;
         deleteAny(gn, Node.ANY, Node.ANY, Node.ANY) ;
     }
-    
+
     private void record(QuadAction action, Node g, Node s, Node p, Node o)
     {
         monitor.change(action, g, s, p, o) ;
     }
-    
+
     @Override
     public void sync() {
         SystemARQ.syncObject(monitor) ;
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/QuadAction.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/QuadAction.java
index 6c73cf9..292a1d3 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/QuadAction.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/QuadAction.java
@@ -22,19 +22,20 @@ package org.apache.jena.sparql.core;
  * <p>
  * {@code DatasetGraph} are sets of quads.
  * An {@code add} only affects the state of the {@code DatasetGraph}
- * if a quad of the same value was not present, 
+ * if a quad of the same value was not present,
  * and a {@code delete} only affects the state of the {@code DatasetGraph}
  * if a quad was present.
  * <p>
  * A {@code QuadAction} can be an {@code ADD} or {@code DELETE}, indicating a change
- * to the {@code DatasetGraph} actually occured (this assumes checking is done - 
+ * to the {@code DatasetGraph} actually occured (this assumes checking is done -
  * {@link DatasetChanges} generators may not check - see implementation for details).
  * Otherwise a {@code NO_ADD}, {@code NO_DELETE} {@code QuadAction} is used.
- */ 
-
+ *
+ * @deprecated Do not use. To see changes to a dataset, use {@link DatasetGraphWrapper} to capture change events.
+ */
+@Deprecated
 public enum QuadAction {
     ADD("A"), DELETE("D"), NO_ADD("#A"), NO_DELETE("#D") ;
     public final String label ;
     QuadAction(String label) { this.label = label ; }
-
 }
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/TS_Core.java b/jena-arq/src/test/java/org/apache/jena/sparql/core/TS_Core.java
index 21152f9..b1173a2 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/core/TS_Core.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/core/TS_Core.java
@@ -34,7 +34,6 @@ import org.junit.runners.Suite ;
     , TestGraphOverDatasetMem.class
     , TestDatasetGraphViewGraphs.class
     , TestGraphView.class
-    , TestDatasetMonitor.class
 
     , TestDatasetGraphBaseFind_General.class
     , TestDatasetGraphBaseFind_Mem.class
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/StorageTDB.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/StorageTDB.java
index 27c914e..db23cba 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/StorageTDB.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/StorageTDB.java
@@ -21,16 +21,13 @@ import java.util.Iterator;
 import java.util.function.Consumer;
 import java.util.function.Supplier;
 
-import org.apache.jena.atlas.lib.InternalErrorException;
 import org.apache.jena.atlas.lib.tuple.Tuple;
 import org.apache.jena.dboe.storage.StorageRDF;
 import org.apache.jena.dboe.transaction.txn.Transaction;
 import org.apache.jena.dboe.transaction.txn.TransactionalSystem;
 import org.apache.jena.graph.Node;
 import org.apache.jena.graph.Triple;
-import org.apache.jena.sparql.core.DatasetChanges;
 import org.apache.jena.sparql.core.Quad;
-import org.apache.jena.sparql.core.QuadAction;
 
 /** {@link StorageRDF} for TDB2 */
 public class StorageTDB implements StorageRDF {
@@ -65,41 +62,9 @@ public class StorageTDB implements StorageRDF {
 
     private void checkActive() {}
 
-    // Watching changes (add, delete, deleteAny)
+    private final void notifyAdd(Node g, Node s, Node p, Node o) { }
 
-    private DatasetChanges monitor = null;
-
-    public void setMonitor(DatasetChanges changes) {
-        monitor = changes;
-    }
-
-    public void unsetMonitor(DatasetChanges changes) {
-        if ( monitor != changes )
-            throw new InternalErrorException();
-        monitor = null;
-    }
-
-    private final void notifyAdd(Node g, Node s, Node p, Node o) {
-        if ( monitor == null )
-            return;
-        QuadAction action = QuadAction.ADD;
-        if ( checkForChange ) {
-            if ( contains(g, s, p, o) )
-                action = QuadAction.NO_ADD;
-        }
-        monitor.change(action, g, s, p, o);
-    }
-
-    private final void notifyDelete(Node g, Node s, Node p, Node o) {
-        if ( monitor == null )
-            return;
-        QuadAction action = QuadAction.DELETE;
-        if ( checkForChange ) {
-            if ( !contains(g, s, p, o) )
-                action = QuadAction.NO_DELETE;
-        }
-        monitor.change(action, g, s, p, o);
-    }
+    private final void notifyDelete(Node g, Node s, Node p, Node o) { }
 
     @Override
     public void add(Node s, Node p, Node o) {
diff --git a/jena-text/src/main/java/org/apache/jena/query/text/DatasetGraphText.java b/jena-text/src/main/java/org/apache/jena/query/text/DatasetGraphText.java
index 7ac956b..d878b4f 100644
--- a/jena-text/src/main/java/org/apache/jena/query/text/DatasetGraphText.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/DatasetGraphText.java
@@ -28,8 +28,8 @@ import org.apache.jena.graph.Graph ;
 import org.apache.jena.graph.Node ;
 import org.apache.jena.query.ReadWrite ;
 import org.apache.jena.query.TxnType;
+import org.apache.jena.query.text.changes.DatasetGraphTextMonitor;
 import org.apache.jena.sparql.core.DatasetGraph;
-import org.apache.jena.sparql.core.DatasetGraphMonitor;
 import org.apache.jena.sparql.core.GraphView;
 import org.apache.jena.sparql.core.Transactional;
 import org.apache.jena.tdb.transaction.TransactionManager;
@@ -37,7 +37,7 @@ import org.apache.lucene.queryparser.classic.QueryParserBase ;
 import org.slf4j.Logger ;
 import org.slf4j.LoggerFactory ;
 
-public class DatasetGraphText extends DatasetGraphMonitor implements Transactional
+public class DatasetGraphText extends DatasetGraphTextMonitor implements Transactional
 {
     private static Logger       log = LoggerFactory.getLogger(DatasetGraphText.class) ;
     private final TextIndex     textIndex ;
@@ -46,26 +46,26 @@ public class DatasetGraphText extends DatasetGraphMonitor implements Transaction
     // Lock needed for commit/abort that perform an index operation and a dataset operation
     // when the underlying datsetGraph does not coordinate the commit.
     private final Object        txnExitLock = new Object();
-    
+
     // If we are going to implement Transactional, then we are going to have to do as DatasetGraphWithLock and
     // TDB's DatasetGraphTransaction do and track transaction state in a ThreadLocal
     private final ThreadLocal<ReadWrite> readWriteMode = new ThreadLocal<>();
-    
+
     private Runnable delegateCommit = ()-> {
         super.commit();
     };
-    
+
     private Runnable delegateAbort = ()-> {
         super.abort();
     };
-    
+
     private Runnable nonDelegatedCommit = ()-> {
         if (readWriteMode.get() == ReadWrite.WRITE)
             commit_W();
         else
             commit_R();
     };
-    
+
     private Runnable nonDelegatedAbort = ()-> {
         if (readWriteMode.get() == ReadWrite.WRITE)
             abort_W();
@@ -75,7 +75,7 @@ public class DatasetGraphText extends DatasetGraphMonitor implements Transaction
 
     private Runnable commitAction = null;
     private Runnable abortAction = null;
-    
+
     public DatasetGraphText(DatasetGraph dsg, TextIndex index, TextDocProducer producer) {
         this(dsg, index, producer, false);
     }
@@ -85,7 +85,7 @@ public class DatasetGraphText extends DatasetGraphMonitor implements Transaction
         this.textIndex = index ;
         dftGraph = GraphView.createDefaultGraph(this) ;
         this.closeIndexOnClose = closeIndexOnClose;
-        
+
         if ( org.apache.jena.tdb.sys.TDBInternal.isTDB1(dsg) ) {
             TransactionManager txnMgr = org.apache.jena.tdb.sys.TDBInternal.getTransactionManager(dsg);
             txnMgr.addAdditionComponent(new TextIndexTDB1(textIndex));
@@ -163,26 +163,26 @@ public class DatasetGraphText extends DatasetGraphMonitor implements Transaction
         }
         begin(TxnType.convert(txnType));
     }
-    
+
     @Override
     public void begin(ReadWrite readWrite) {
         // Do not synchronized(txnLock) here. It will deadlock because if there
-        // is an writer in commit, it can't 
-        
+        // is an writer in commit, it can't
+
         // The "super.begin" is enough.
         readWriteMode.set(readWrite);
         super.begin(readWrite) ;
         super.getMonitor().start() ;
     }
-    
+
     @Override
     public void commit() {
         super.getMonitor().finish() ;
         commitAction.run();
         readWriteMode.set(null);
     }
-    
-    
+
+
     /**
      * Rollback all changes, discarding any exceptions that occur.
      */
@@ -208,13 +208,13 @@ public class DatasetGraphText extends DatasetGraphMonitor implements Transaction
                 abort();
                 throw new TextIndexException(t);
             }
-            
+
             // Phase 2
             try {
                 // JENA-1302: This needs the exclusive lock for flushing the queue.
                 // TDB1
                 // Thread 1(W) is running, holds the exclusivitylock=R
-                
+
                 // Thread 2(W) starts, tries to commit
                 //   Takes txnExitLock
                 //   Calls super.commit
@@ -224,25 +224,25 @@ public class DatasetGraphText extends DatasetGraphMonitor implements Transaction
                 //       So Thread 2 blocks, waiting for thread 1
                 //       but still holds txnExitLock
                 //
-                // Thread 1 tries to commit. 
+                // Thread 1 tries to commit.
                 //   Can't take the txnExitLock because of thread 2.
                 //
                 // ==> Deadlock.
                 // Fix:
                 //   Put index commit into TDB TransactionLifecycle.
                 //   No txnExitLock.
-                
+
                 // Doing a non-blocking exclusive attempt in TransactionManger.exclusiveFlushQueue
                 // does not help - we are in a situation where the queue is growing and unflushable
                 // which is why we entered emergency measures. Eventually, RAM will run out as well as
-                // the system becoming slow due to Journal layers. 
-                
+                // the system becoming slow due to Journal layers.
+
                 // TDB2
                 //   All work takes place on the W commiting thread.
                 //   There is no pause point so this can't happen.
-                //     txnExitLock isn't needed, the overall TDB2 transaction 
+                //     txnExitLock isn't needed, the overall TDB2 transaction
                 //     means W is unique and all work happens without any potential blocking.
-                
+
                 super.commit();
                 textIndex.commit();
             }
@@ -258,7 +258,7 @@ public class DatasetGraphText extends DatasetGraphMonitor implements Transaction
         try { super.abort() ; }
         catch (Throwable t) { log.warn("Exception in abort: " + t.getMessage(), t); }
     }
-    
+
     private void abort_W() {
         synchronized(txnExitLock) {
             // Roll back on both objects, discarding any exceptions that occur
@@ -287,12 +287,12 @@ public class DatasetGraphText extends DatasetGraphMonitor implements Transaction
         super.getMonitor().finish() ;
         readWriteMode.set(null) ;
     }
-    
+
     @Override
     public boolean supportsTransactions() {
         return super.supportsTransactions() ;
     }
-    
+
     /** Declare whether {@link #abort} is supported.
      *  This goes along with clearing up after exceptions inside application transaction code.
      */
@@ -300,7 +300,7 @@ public class DatasetGraphText extends DatasetGraphMonitor implements Transaction
     public boolean supportsTransactionAbort() {
         return super.supportsTransactionAbort() ;
     }
-    
+
     @Override
     public void close() {
         super.close();
diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducer.java b/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducer.java
index 5614482..035d7ad 100644
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducer.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducer.java
@@ -18,7 +18,7 @@
 
 package org.apache.jena.query.text;
 
-import org.apache.jena.sparql.core.DatasetChanges ;
+import org.apache.jena.query.text.changes.TextDatasetChanges;
 
 /**
  * Responsible for monitoring changes on a dataset and updating the TextIndex appropriately.
@@ -26,7 +26,7 @@ import org.apache.jena.sparql.core.DatasetChanges ;
  * <strong>Note:</strong> If implementation is to be instantiated dynamically via an Assembler, it must
  * contain a constructor that accepts a single parameter of type {@link org.apache.jena.query.text.TextIndex}
  */
-public interface TextDocProducer extends DatasetChanges
+public interface TextDocProducer extends TextDatasetChanges
 {
 
 }
diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducerEntities.java b/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducerEntities.java
index dce81cd..ea3f05b 100644
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducerEntities.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducerEntities.java
@@ -21,20 +21,20 @@ package org.apache.jena.query.text ;
 import java.util.List ;
 
 import org.apache.jena.graph.Node ;
-import org.apache.jena.sparql.core.DatasetChangesBatched ;
+import org.apache.jena.query.text.changes.ChangesBatched;
+import org.apache.jena.query.text.changes.TextQuadAction;
 import org.apache.jena.sparql.core.Quad ;
-import org.apache.jena.sparql.core.QuadAction ;
 import org.apache.jena.sparql.util.FmtUtils ;
 import org.slf4j.Logger ;
 import org.slf4j.LoggerFactory ;
 
-// Currently unused 
+// Currently unused
 // This would index multiple quads at a time from batched stream of changes (e.g. rdf-patch)
-public class TextDocProducerEntities extends DatasetChangesBatched implements TextDocProducer {
+public class TextDocProducerEntities extends ChangesBatched implements TextDocProducer {
     private static Logger          log     = LoggerFactory.getLogger(TextDocProducer.class) ;
     private final EntityDefinition defn ;
     private final TextIndex        indexer ;
-    
+
     // Have to have a ThreadLocal here to keep track of whether or not we are in a transaction,
     // therefore whether or not we have to do autocommit
     private final ThreadLocal<Boolean> inTransaction = new ThreadLocal<Boolean>() {
@@ -61,10 +61,10 @@ public class TextDocProducerEntities extends DatasetChangesBatched implements Te
     }
 
     @Override
-    protected void dispatch(QuadAction quadAction, List<Quad> batch) {
+    protected void dispatch(TextQuadAction quadAction, List<Quad> batch) {
         if ( !inTransaction.get() )
             throw new IllegalStateException("Not started") ;
-        if ( !QuadAction.ADD.equals(quadAction) )
+        if ( !TextQuadAction.ADD.equals(quadAction) )
             return ;
         if ( batch.size() == 0 )
             return ;
@@ -87,7 +87,7 @@ public class TextDocProducerEntities extends DatasetChangesBatched implements Te
         String graphField = defn.getGraphField() ;
         if ( defn.getGraphField() != null )
             entity.put(graphField, gx) ;
-        
+
         for ( Quad quad : batch ) {
             Node p = quad.getPredicate() ;
             String field = defn.getField(p) ;
diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducerTriples.java b/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducerTriples.java
index f641924..98f0c81 100644
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducerTriples.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextDocProducerTriples.java
@@ -19,7 +19,7 @@
 package org.apache.jena.query.text ;
 
 import org.apache.jena.graph.Node ;
-import org.apache.jena.sparql.core.QuadAction ;
+import org.apache.jena.query.text.changes.TextQuadAction;
 import org.slf4j.Logger ;
 import org.slf4j.LoggerFactory ;
 
@@ -27,7 +27,7 @@ public class TextDocProducerTriples implements TextDocProducer {
     private static Logger          log     = LoggerFactory.getLogger(TextDocProducerTriples.class) ;
     private final EntityDefinition defn ;
     private final TextIndex        indexer ;
-    
+
     // Have to have a ThreadLocal here to keep track of whether or not we are in a transaction,
     // therefore whether or not we have to do autocommit
     private final ThreadLocal<Boolean> inTransaction = new ThreadLocal<Boolean>() {
@@ -36,7 +36,7 @@ public class TextDocProducerTriples implements TextDocProducer {
             return Boolean.FALSE ;
         }
     } ;
-    
+
     public TextDocProducerTriples(TextIndex indexer) {
         this.defn = indexer.getDocDef() ;
         this.indexer = indexer ;
@@ -56,18 +56,18 @@ public class TextDocProducerTriples implements TextDocProducer {
     public void reset() { }
 
     @Override
-    public void change(QuadAction qaction, Node g, Node s, Node p, Node o) {
+    public void change(TextQuadAction qaction, Node g, Node s, Node p, Node o) {
         // One document per triple/quad
 
-        if ( qaction != QuadAction.ADD &&
-             qaction != QuadAction.DELETE )
+        if ( qaction != TextQuadAction.ADD &&
+             qaction != TextQuadAction.DELETE )
             return ;
 
 
         Entity entity = TextQueryFuncs.entityFromQuad(defn, g, s, p, o) ;
         // Null means does not match defn
         if ( entity != null ) {
-            if (qaction == QuadAction.ADD) {
+            if (qaction == TextQuadAction.ADD) {
                 indexer.addEntity(entity);
 
                 // Auto commit the entity if we aren't in a transaction
@@ -75,7 +75,7 @@ public class TextDocProducerTriples implements TextDocProducer {
                     indexer.commit();
                 }
             }
-            else if (qaction == QuadAction.DELETE) {
+            else if (qaction == TextQuadAction.DELETE) {
                 indexer.deleteEntity(entity);
 
                 // Auto commit the entity if we aren't in a transaction
diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexTDB1.java b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexTDB1.java
index f7c6a3d..a42f0d1 100644
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexTDB1.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexTDB1.java
@@ -31,7 +31,7 @@ public class TextIndexTDB1 implements TransactionLifecycle {
     public TextIndexTDB1(TextIndex textIndex) {
         this.textIndex = textIndex;
     }
-    
+
     @Override
     public void begin(Transaction txn) {
     }
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesBatched.java b/jena-text/src/main/java/org/apache/jena/query/text/changes/ChangesBatched.java
similarity index 85%
copy from jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesBatched.java
copy to jena-text/src/main/java/org/apache/jena/query/text/changes/ChangesBatched.java
index 7dcdff6..0010a46 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesBatched.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/changes/ChangesBatched.java
@@ -16,26 +16,27 @@
  * limitations under the License.
  */
 
-package org.apache.jena.sparql.core ;
+package org.apache.jena.query.text.changes ;
 
 import java.util.ArrayList ;
 import java.util.List ;
 import java.util.Objects ;
 
 import org.apache.jena.graph.Node ;
+import org.apache.jena.sparql.core.Quad;
 
 /**
  * Collect a stream of DatasetChanges into batches. A batch is adjacent quads
  * changes with (same graph, same subject, same action).
  */
-public abstract class DatasetChangesBatched implements DatasetChanges {
-    private QuadAction currentAction   = null ;
+public abstract class ChangesBatched implements TextDatasetChanges {
+    private TextQuadAction currentAction   = null ;
     private Node       currentSubject  = null ;
     private Node       currentGraph    = null ;
     private List<Quad> batchQuads      = null ;
     private boolean    mergeBlankNodes = false ;
 
-    protected DatasetChangesBatched() {
+    protected ChangesBatched() {
         this(false) ;
     }
 
@@ -43,7 +44,7 @@ public abstract class DatasetChangesBatched implements DatasetChanges {
      * Merge bNodes in a batch - i.e. include them in the current batch, not as
      * new entities
      */
-    protected DatasetChangesBatched(boolean mergeBNodes) {
+    protected ChangesBatched(boolean mergeBNodes) {
         this.mergeBlankNodes = mergeBNodes ;
     }
 
@@ -63,7 +64,7 @@ public abstract class DatasetChangesBatched implements DatasetChanges {
     public final void reset() { }
 
     @Override
-    public void change(QuadAction qaction, Node g, Node s, Node p, Node o) {
+    public void change(TextQuadAction qaction, Node g, Node s, Node p, Node o) {
         if ( mergeBlankNodes && s.isBlank() ) {
             if ( batchQuads == null )
                 // No active batch.
@@ -92,7 +93,7 @@ public abstract class DatasetChangesBatched implements DatasetChanges {
         batchQuads = null ;
     }
 
-    protected abstract void dispatch(QuadAction quadAction, List<Quad> batch) ;
+    protected abstract void dispatch(TextQuadAction quadAction, List<Quad> batch) ;
 
     protected abstract void startBatched() ;
 
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMonitor.java b/jena-text/src/main/java/org/apache/jena/query/text/changes/DatasetGraphTextMonitor.java
similarity index 75%
copy from jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMonitor.java
copy to jena-text/src/main/java/org/apache/jena/query/text/changes/DatasetGraphTextMonitor.java
index 8ae5509..942ab8c 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMonitor.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/changes/DatasetGraphTextMonitor.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.jena.sparql.core ;
+package org.apache.jena.query.text.changes ;
 
 import static org.apache.jena.atlas.iterator.Iter.take ;
 import static org.apache.jena.sparql.core.GraphView.createDefaultGraph;
@@ -29,22 +29,24 @@ import org.apache.jena.graph.Graph ;
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.Triple ;
 import org.apache.jena.sparql.SystemARQ ;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphWrapper;
+import org.apache.jena.sparql.core.Quad;
 import org.apache.jena.util.iterator.ExtendedIterator ;
 
 /** Connect a DatasetGraph to a DatasetChanges monitor.
  *  Any add or delete to the DatasetGraph is notified to the
- *  monitoring object with a {@link QuadAction} to indicate
- *  the change made.   
+ *  monitoring object with a {@link TextQuadAction} to indicate
+ *  the change made.
  */
-
-public class DatasetGraphMonitor extends DatasetGraphWrapper
+public class DatasetGraphTextMonitor extends DatasetGraphWrapper
 {
-    /** Whether to see if a quad action will change the dataset - test before add for existence, test before delete for absence */   
+    /** Whether to see if a quad action will change the dataset - test before add for existence, test before delete for absence */
     private boolean CheckFirst = true ;
-    /** Whether to record a no-op (maybe as a comment) */   
+    /** Whether to record a no-op (maybe as a comment) */
     private boolean RecordNoAction = true ;
-    /** Where to send the notifications */  
-    private final DatasetChanges monitor ;
+    /** Where to send the notifications */
+    private final TextDatasetChanges monitor ;
 
     /**
      * Create a DatasetGraph wrapper that monitors the dataset for changes (add or delete quads).
@@ -52,11 +54,11 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
      * Note whether additions of deletions cause an actual change to the dataset or not.
      * @param dsg       The DatasetGraph to monitor
      * @param monitor   The handler for a change
-     *         
-     * @see DatasetChanges
-     * @see QuadAction
+     *
+     * @see TextDatasetChanges
+     * @see TextQuadAction
      */
-    public DatasetGraphMonitor(DatasetGraph dsg, DatasetChanges monitor) 
+    public DatasetGraphTextMonitor(DatasetGraph dsg, TextDatasetChanges monitor)
     {
         super(dsg) ;
         this.monitor = monitor ;
@@ -64,26 +66,26 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
 
     /**
      * Create a DatasetGraph wrapper that monitors the dataset for changes (add or delete quads).
-     * Use this DatasetGraph for all operations in order to record changes.  
+     * Use this DatasetGraph for all operations in order to record changes.
      * @param dsg       The DatasetGraph to monitor
      * @param monitor   The handler for a change
      * @param recordOnlyIfRealChange
      *         If true, check to see if the change would have an effect (e.g. add is a new quad).
      *         If false, log changes as ADD/DELETE regardless of whether the dataset actually changes.
-     *         
-     * @see DatasetChanges
-     * @see QuadAction
+     *
+     * @see TextDatasetChanges
+     * @see TextQuadAction
      */
-    public DatasetGraphMonitor(DatasetGraph dsg, DatasetChanges monitor, boolean recordOnlyIfRealChange) 
+    public DatasetGraphTextMonitor(DatasetGraph dsg, TextDatasetChanges monitor, boolean recordOnlyIfRealChange)
     {
         super(dsg) ;
         CheckFirst = recordOnlyIfRealChange ;
         this.monitor = monitor ;
     }
 
-    /** Return the monitor */ 
-    public DatasetChanges getMonitor()      { return monitor ; }
-    
+    /** Return the monitor */
+    public TextDatasetChanges getMonitor()      { return monitor ; }
+
     /** Return the monitored DatasetGraph */
     public DatasetGraph   monitored()       { return getWrapped() ; }
 
@@ -92,34 +94,34 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
         if ( CheckFirst && contains(quad) )
         {
             if ( RecordNoAction )
-                record(QuadAction.NO_ADD, quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
+                record(TextQuadAction.NO_ADD, quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
             return ;
         }
         add$(quad) ;
     }
-    
+
     @Override public void add(Node g, Node s, Node p, Node o)
     {
         if ( CheckFirst && contains(g,s,p,o) )
         {
             if ( RecordNoAction )
-                record(QuadAction.NO_ADD,g,s,p,o) ; 
+                record(TextQuadAction.NO_ADD,g,s,p,o) ;
             return ;
         }
-        
+
         add$(g,s,p,o) ;
     }
-    
+
     private void add$(Node g, Node s, Node p, Node o)
     {
         super.add(g,s,p,o) ;
-        record(QuadAction.ADD,g,s,p,o) ; 
+        record(TextQuadAction.ADD,g,s,p,o) ;
     }
-    
+
     private void add$(Quad quad)
     {
         super.add(quad) ;
-        record(QuadAction.ADD, quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
+        record(TextQuadAction.ADD, quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
     }
 
     @Override public void delete(Quad quad)
@@ -127,52 +129,52 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
         if ( CheckFirst && ! contains(quad) )
         {
             if ( RecordNoAction )
-                record(QuadAction.NO_DELETE, quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
+                record(TextQuadAction.NO_DELETE, quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
             return ;
         }
         delete$(quad) ;
     }
-    
+
     @Override public void delete(Node g, Node s, Node p, Node o)
     {
         if ( CheckFirst && ! contains(g,s,p,o) )
         {
             if ( RecordNoAction )
-                record(QuadAction.NO_DELETE, g,s,p,o) ;
+                record(TextQuadAction.NO_DELETE, g,s,p,o) ;
             return ;
         }
         delete$(g,s,p,o) ;
     }
-    
+
     private void delete$(Quad quad)
     {
         super.delete(quad) ;
-        record(QuadAction.DELETE, quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
+        record(TextQuadAction.DELETE, quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()) ;
     }
-    
+
     private void delete$(Node g, Node s, Node p, Node o)
     {
         super.delete(g,s,p,o) ;
-        record(QuadAction.DELETE,g,s,p,o) ; 
+        record(TextQuadAction.DELETE,g,s,p,o) ;
     }
-    
+
 
     private static int SLICE = 1000 ;
-    
+
     @Override
     public void deleteAny(Node g, Node s, Node p, Node o)
     {
         while (true)
         {
             Iterator<Quad> iter = find(g, s, p, o) ;
-            // Materialize - stops possible ConcurrentModificationExceptions 
+            // Materialize - stops possible ConcurrentModificationExceptions
             List<Quad> some = take(iter, SLICE) ;
             for (Quad q : some)
                 delete$(q) ;
             if (some.size() < SLICE) break ;
         }
     }
-    
+
     @Override public void addGraph(Node gn, Graph g)
     {
         // Convert to quads.
@@ -184,18 +186,18 @@ public class DatasetGraphMonitor extends DatasetGraphWrapper
             add(gn, t.getSubject(), t.getPredicate(), t.getObject()) ;
         }
     }
-    
+
     @Override public void removeGraph(Node gn)
     {
         //super.removeGraph(gn) ;
         deleteAny(gn, Node.ANY, Node.ANY, Node.ANY) ;
     }
-    
-    private void record(QuadAction action, Node g, Node s, Node p, Node o)
+
+    private void record(TextQuadAction action, Node g, Node s, Node p, Node o)
     {
         monitor.change(action, g, s, p, o) ;
     }
-    
+
     @Override
     public void sync() {
         SystemARQ.syncObject(monitor) ;
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChanges.java b/jena-text/src/main/java/org/apache/jena/query/text/changes/TextDatasetChanges.java
similarity index 86%
copy from jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChanges.java
copy to jena-text/src/main/java/org/apache/jena/query/text/changes/TextDatasetChanges.java
index e667e6f..dbda8a0 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChanges.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/changes/TextDatasetChanges.java
@@ -16,22 +16,22 @@
  * limitations under the License.
  */
 
-package org.apache.jena.sparql.core;
+package org.apache.jena.query.text.changes;
 
 import org.apache.jena.graph.Node ;
 
 /** Interface for notification of changes
  * (adds and deletes of quads) to a DatasetGraph
  */
-public interface DatasetChanges
+public interface TextDatasetChanges
 {
     /** Indicator that a sequence of changes is about to start */
     public void start() ;
 
     /** A change has occurred
-     * @see QuadAction
+     * @see TextQuadAction
      */
-    public void change(QuadAction qaction, Node g, Node s, Node p, Node o) ;
+    public void change(TextQuadAction qaction, Node g, Node s, Node p, Node o) ;
 
     /** Indicator that a sequence of changes has now finished */
     public void finish() ;
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/QuadAction.java b/jena-text/src/main/java/org/apache/jena/query/text/changes/TextQuadAction.java
similarity index 83%
copy from jena-arq/src/main/java/org/apache/jena/sparql/core/QuadAction.java
copy to jena-text/src/main/java/org/apache/jena/query/text/changes/TextQuadAction.java
index 6c73cf9..2aa819d 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/QuadAction.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/changes/TextQuadAction.java
@@ -16,25 +16,23 @@
  * limitations under the License.
  */
 
-package org.apache.jena.sparql.core;
+package org.apache.jena.query.text.changes;
 
 /** A {@code QuadAction} is record of a type of change to a {@code DatasetGraph}.
  * <p>
  * {@code DatasetGraph} are sets of quads.
  * An {@code add} only affects the state of the {@code DatasetGraph}
- * if a quad of the same value was not present, 
+ * if a quad of the same value was not present,
  * and a {@code delete} only affects the state of the {@code DatasetGraph}
  * if a quad was present.
  * <p>
  * A {@code QuadAction} can be an {@code ADD} or {@code DELETE}, indicating a change
- * to the {@code DatasetGraph} actually occured (this assumes checking is done - 
- * {@link DatasetChanges} generators may not check - see implementation for details).
+ * to the {@code DatasetGraph} actually occured (this assumes checking is done -
+ * {@link TextDatasetChanges} generators may not check - see implementation for details).
  * Otherwise a {@code NO_ADD}, {@code NO_DELETE} {@code QuadAction} is used.
- */ 
-
-public enum QuadAction {
+ */
+public enum TextQuadAction {
     ADD("A"), DELETE("D"), NO_ADD("#A"), NO_DELETE("#D") ;
     public final String label ;
-    QuadAction(String label) { this.label = label ; }
-
+    TextQuadAction(String label) { this.label = label ; }
 }
diff --git a/jena-text/src/test/java/org/apache/jena/query/text/TS_Text.java b/jena-text/src/test/java/org/apache/jena/query/text/TS_Text.java
index 6031f97..fe8762f 100644
--- a/jena-text/src/test/java/org/apache/jena/query/text/TS_Text.java
+++ b/jena-text/src/test/java/org/apache/jena/query/text/TS_Text.java
@@ -21,6 +21,7 @@ package org.apache.jena.query.text;
 import org.apache.jena.query.text.assembler.TestEntityMapAssembler;
 import org.apache.jena.query.text.assembler.TestTextDatasetAssembler;
 import org.apache.jena.query.text.assembler.TestTextIndexLuceneAssembler;
+import org.apache.jena.query.text.changes.TestDatasetMonitor;
 import org.apache.jena.query.text.assembler.TestGenericAnalyzerAssembler;
 import org.apache.jena.query.text.assembler.TestPropListsAssembler;
 import org.junit.runner.RunWith;
@@ -31,13 +32,15 @@ import org.junit.runners.Suite.SuiteClasses;
 @SuiteClasses({
 
     TestBuildTextDataset.class
+    , TestDatasetMonitor.class
+
     , TestDatasetWithLuceneTextIndex.class
     , TestDatasetWithLuceneMultilingualTextIndex.class
     , TestDatasetWithLuceneTextIndexWithLangField.class
     , TestDatasetWithLuceneGraphTextIndex.class
     , TestDatasetWithLuceneTextIndexDeletionSupport.class
     , TestDatasetWithLuceneStoredLiterals.class
-    
+
     , TestTextNonTxn.class
     , TestTextTxn.class
     , TestTextNonTxnTDB1.class
@@ -62,11 +65,12 @@ import org.junit.runners.Suite.SuiteClasses;
     , TestTextHighlighting.class
     , TestTextDefineAnalyzers.class
     , TestTextMultilingualEnhancements.class
-    
+
     , TestPropListsAssembler.class
     , TestTextPropLists.class
     , TestTextPropLists02.class
     , TestTextMultilingualEnhancements02.class
+
 })
 
 public class TS_Text
diff --git a/jena-text/src/test/java/org/apache/jena/query/text/assembler/TestTextDatasetAssembler.java b/jena-text/src/test/java/org/apache/jena/query/text/assembler/TestTextDatasetAssembler.java
index f71fe3f..5000c6d 100644
--- a/jena-text/src/test/java/org/apache/jena/query/text/assembler/TestTextDatasetAssembler.java
+++ b/jena-text/src/test/java/org/apache/jena/query/text/assembler/TestTextDatasetAssembler.java
@@ -20,19 +20,13 @@ package org.apache.jena.query.text.assembler;
 
 import static org.junit.Assert.assertTrue ;
 
-import java.util.Iterator;
-
 import org.apache.jena.assembler.Assembler ;
 import org.apache.jena.assembler.exceptions.AssemblerException;
 import org.apache.jena.graph.Node ;
-import org.apache.jena.graph.NodeFactory ;
 import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.ReadWrite ;
 import org.apache.jena.query.text.* ;
+import org.apache.jena.query.text.changes.TextQuadAction;
 import org.apache.jena.rdf.model.Resource ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.core.Quad ;
-import org.apache.jena.sparql.core.QuadAction ;
 import org.apache.jena.sys.JenaSystem;
 import org.apache.jena.tdb.assembler.AssemblerTDB ;
 import org.apache.jena.tdb.sys.TDBInternal;
@@ -53,16 +47,15 @@ public class TestTextDatasetAssembler extends AbstractTestTextAssembler {
     private static final Resource noDatasetPropertySpec;
     private static final Resource noIndexPropertySpec;
     private static final Resource customTextDocProducerSpec;
-    private static final Resource customDyadicTextDocProducerSpec;
 
     @BeforeClass public static void clearBefore() {
         TDBInternal.reset();
     }
-    
+
     @After public void clearAfter() {
         TDBInternal.reset();
     }
-    
+
     @Test
     public void testSimpleDatasetAssembler() {
         Dataset dataset = (Dataset) Assembler.general.open(spec1);
@@ -88,22 +81,6 @@ public class TestTextDatasetAssembler extends AbstractTestTextAssembler {
         dataset.close();
     }
 
-    @Test
-    public void testCustomTextDocProducerDyadicConstructor() {
-        Dataset dataset = (Dataset)Assembler.general.open(customDyadicTextDocProducerSpec) ;
-        DatasetGraphText dsgText = (DatasetGraphText)dataset.asDatasetGraph() ;
-        assertTrue(dsgText.getMonitor() instanceof CustomDyadicTextDocProducer) ;
-
-        Node G = NodeFactory.createURI("http://example.com/G");
-        Node S = NodeFactory.createURI("http://example.com/S");
-        Node P = NodeFactory.createURI("http://example.com/P");
-        Node O = NodeFactory.createLiteral("http://example.com/O");
-
-        dsgText.begin(ReadWrite.WRITE);
-        dsgText.add(G, S, P, O);
-        dsgText.commit();
-    }
-
     static {
         JenaSystem.init();
         TextAssembler.init();
@@ -127,13 +104,6 @@ public class TestTextDatasetAssembler extends AbstractTestTextAssembler {
                  .addProperty(TextVocab.pDataset, SIMPLE_DATASET_SPEC)
                  .addProperty(TextVocab.pIndex, SIMPLE_INDEX_SPEC5)
                  .addProperty(TextVocab.pTextDocProducer, model.createResource("java:org.apache.jena.query.text.assembler.TestTextDatasetAssembler$CustomTextDocProducer"));
-
-        customDyadicTextDocProducerSpec =
-            model.createResource(TESTBASE + "customDyadicTextDocProducerSpec")
-                 .addProperty(RDF.type, TextVocab.textDataset)
-                 .addProperty(TextVocab.pDataset, SIMPLE_DATASET_SPEC)
-                 .addProperty(TextVocab.pIndex, SIMPLE_INDEX_SPEC5)
-                 .addProperty(TextVocab.pTextDocProducer, model.createResource("java:org.apache.jena.query.text.assembler.TestTextDatasetAssembler$CustomDyadicTextDocProducer"));
     }
 
     private static class CustomTextDocProducer implements TextDocProducer {
@@ -147,38 +117,9 @@ public class TestTextDatasetAssembler extends AbstractTestTextAssembler {
         public void finish() { }
 
         @Override
-        public void change(QuadAction qaction, Node g, Node s, Node p, Node o) { }
+        public void change(TextQuadAction qaction, Node g, Node s, Node p, Node o) { }
 
         @Override
         public void reset() {}
     }
-
-
-    private static class CustomDyadicTextDocProducer implements TextDocProducer {
-
-        final DatasetGraph dg;
-        Node lastSubject = null;
-
-        public CustomDyadicTextDocProducer(DatasetGraph dg, TextIndex textIndex) { 
-            this.dg = dg;
-        }
-
-        @Override
-        public void start() { }
-
-        @Override
-        public void finish() { 
-            Iterator<Quad> qi = dg.find(null, lastSubject, Node.ANY, Node.ANY);
-            while (qi.hasNext()) qi.next();
-        }
-
-        @Override
-        public void change(QuadAction qaction, Node g, Node s, Node p, Node o) { 
-            lastSubject = s;
-        }
-
-        @Override
-        public void reset() {}
-    }
-
 }
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCapture.java b/jena-text/src/test/java/org/apache/jena/query/text/changes/ChangesCapture.java
similarity index 79%
copy from jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCapture.java
copy to jena-text/src/test/java/org/apache/jena/query/text/changes/ChangesCapture.java
index 0c72ffd..2306aee 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCapture.java
+++ b/jena-text/src/test/java/org/apache/jena/query/text/changes/ChangesCapture.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.jena.sparql.core ;
+package org.apache.jena.query.text.changes ;
 
 import java.util.Collections ;
 import java.util.LinkedList ;
@@ -24,9 +24,11 @@ import java.util.List ;
 
 import org.apache.jena.atlas.lib.Pair ;
 import org.apache.jena.graph.Node ;
+import org.apache.jena.sparql.core.Quad;
 
-/** Capture a record of quad actions */
-public class DatasetChangesCapture implements DatasetChanges {
+/** Capture a record of quad actions
+ */
+public class ChangesCapture implements TextDatasetChanges {
     // ArrayLists have an annoying issue that they grow by copying the internal
     // []-array.
     // This growth is by a fixed factor of adding 50% which for an array
@@ -34,30 +36,30 @@ public class DatasetChangesCapture implements DatasetChanges {
     // and copy-time issues.
     // Using a LinkedList avoids this although it adds overhead for list
     // entries.
-    private List<Pair<QuadAction, Quad>> actions ;
+    private List<Pair<TextQuadAction, Quad>> actions ;
     final private boolean                captureAdd ;
     final private boolean                captureDelete ;
     final private boolean                captureNoAdd ;
     final private boolean                captureNoDelete ;
 
     /** Capture quad actions, excluding no-ops */
-    public DatasetChangesCapture() {
+    public ChangesCapture() {
         this(true, true, false, false) ;
     }
 
     /**
      * Capture quad actions, either including or excluding the "no ops"
-     * 
+     *
      * @param recordNoOps
-     *            Whether to record {@link QuadAction#NO_ADD} and
-     *            {@link QuadAction#NO_DELETE}
+     *            Whether to record {@link TextQuadAction#NO_ADD} and
+     *            {@link TextQuadAction#NO_DELETE}
      */
-    public DatasetChangesCapture(boolean recordNoOps) {
+    public ChangesCapture(boolean recordNoOps) {
         this(true, true, recordNoOps, recordNoOps) ;
     }
 
     /** Capture quad actions, selectively by category */
-    public DatasetChangesCapture(boolean captureAdd, boolean captureDelete, boolean captureNoAdd, boolean captureNoDelete) {
+    public ChangesCapture(boolean captureAdd, boolean captureDelete, boolean captureNoAdd, boolean captureNoDelete) {
         this.captureAdd = captureAdd ;
         this.captureDelete = captureDelete ;
         this.captureNoAdd = captureNoAdd ;
@@ -66,9 +68,9 @@ public class DatasetChangesCapture implements DatasetChanges {
     }
 
     /** The actions recorded.
-     *  Only valid until the next {@code start} call.   
+     *  Only valid until the next {@code start} call.
      */
-    public List<Pair<QuadAction, Quad>> getActions() {
+    public List<Pair<TextQuadAction, Quad>> getActions() {
         return Collections.unmodifiableList(actions) ;
     }
 
@@ -79,9 +81,9 @@ public class DatasetChangesCapture implements DatasetChanges {
     }
 
     @Override
-    public void change(QuadAction qaction, Node g, Node s, Node p, Node o) {
+    public void change(TextQuadAction qaction, Node g, Node s, Node p, Node o) {
         Quad q = new Quad(g, s, p, o) ;
-        Pair<QuadAction, Quad> pair = Pair.create(qaction, q) ;
+        Pair<TextQuadAction, Quad> pair = Pair.create(qaction, q) ;
 
         switch (qaction) {
             case ADD :
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCounter.java b/jena-text/src/test/java/org/apache/jena/query/text/changes/ChangesCounter.java
similarity index 75%
copy from jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCounter.java
copy to jena-text/src/test/java/org/apache/jena/query/text/changes/ChangesCounter.java
index 3a157e6..0093c7c 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetChangesCounter.java
+++ b/jena-text/src/test/java/org/apache/jena/query/text/changes/ChangesCounter.java
@@ -16,28 +16,29 @@
  * limitations under the License.
  */
 
-package org.apache.jena.sparql.core;
+package org.apache.jena.query.text.changes;
 
 import org.apache.jena.graph.Node ;
 
-/** Count changes, or simply note if a change has been made. */
-public class DatasetChangesCounter implements DatasetChanges
+/** Count changes, or simply note if a change has been made.
+ */
+public class ChangesCounter implements TextDatasetChanges
 {
-    long countStart    = 0 ;
-    long countFinish   = 0 ;
-    
-    long countAdd      = 0 ;
-    long countDelete   = 0 ;
-    long countNoAdd    = 0 ;
-    long countNoDelete = 0 ;
-    
+    public long countStart    = 0 ;
+    public long countFinish   = 0 ;
+
+    public long countAdd      = 0 ;
+    public long countDelete   = 0 ;
+    public long countNoAdd    = 0 ;
+    public long countNoDelete = 0 ;
+
     @Override
     public void start() {
         countStart++ ;
     }
 
     @Override
-    public void change(QuadAction qaction, Node g, Node s, Node p, Node o) {
+    public void change(TextQuadAction qaction, Node g, Node s, Node p, Node o) {
         if ( qaction == null )
             throw new NullPointerException() ;
         switch (qaction) {
@@ -45,7 +46,7 @@ public class DatasetChangesCounter implements DatasetChanges
             case DELETE:    countDelete++ ; break ;
             case NO_ADD:    countNoAdd++ ; break ;
             case NO_DELETE: countNoDelete++ ; break ;
-            //default : break ;        
+            //default : break ;
         }
     }
 
@@ -53,16 +54,16 @@ public class DatasetChangesCounter implements DatasetChanges
     public void finish() {
         countFinish++ ;
     }
-    
+
     public boolean hasChanged() {
         return countAdd > 0 || countDelete > 0 ;
     }
-    
+
     @Override
-    public void reset() { 
+    public void reset() {
         countStart    = 0 ;
         countFinish   = 0 ;
-        
+
         countAdd      = 0 ;
         countDelete   = 0 ;
         countNoAdd    = 0 ;
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/TestDatasetMonitor.java b/jena-text/src/test/java/org/apache/jena/query/text/changes/TestDatasetMonitor.java
similarity index 68%
rename from jena-arq/src/test/java/org/apache/jena/sparql/core/TestDatasetMonitor.java
rename to jena-text/src/test/java/org/apache/jena/query/text/changes/TestDatasetMonitor.java
index caafed9..6d8ef34 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/core/TestDatasetMonitor.java
+++ b/jena-text/src/test/java/org/apache/jena/query/text/changes/TestDatasetMonitor.java
@@ -16,12 +16,12 @@
  * limitations under the License.
  */
 
-package org.apache.jena.sparql.core;
+package org.apache.jena.query.text.changes;
 
-import static org.apache.jena.sparql.core.QuadAction.ADD ;
-import static org.apache.jena.sparql.core.QuadAction.DELETE ;
-import static org.apache.jena.sparql.core.QuadAction.NO_ADD ;
-import static org.apache.jena.sparql.core.QuadAction.NO_DELETE ;
+import static org.apache.jena.query.text.changes.TextQuadAction.ADD;
+import static org.apache.jena.query.text.changes.TextQuadAction.DELETE;
+import static org.apache.jena.query.text.changes.TextQuadAction.NO_ADD;
+import static org.apache.jena.query.text.changes.TextQuadAction.NO_DELETE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -30,6 +30,9 @@ import java.util.List ;
 import org.apache.jena.atlas.lib.Pair ;
 import org.apache.jena.graph.Graph;
 import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphFactory;
+import org.apache.jena.sparql.core.Quad;
 import org.apache.jena.sparql.sse.SSE ;
 import org.junit.Test ;
 
@@ -42,8 +45,8 @@ public class TestDatasetMonitor
 
     @Test public void countChanges_01() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCounter dsgChanges = new DatasetChangesCounter() ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgChanges) ;
+        ChangesCounter dsgChanges = new ChangesCounter() ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgChanges) ;
 
         check(dsgChanges, 0, 0, 0, 0) ;
         dsg.add(quad1) ;
@@ -52,9 +55,9 @@ public class TestDatasetMonitor
 
     @Test public void countChanges_02() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCounter dsgChanges = new DatasetChangesCounter() ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgChanges) ;
-        
+        ChangesCounter dsgChanges = new ChangesCounter() ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgChanges) ;
+
         check(dsgChanges, 0, 0, 0, 0) ;
         dsg.add(quad1) ;
         dsg.delete(quad1) ;
@@ -63,8 +66,8 @@ public class TestDatasetMonitor
 
     @Test public void countChanges_03() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCounter dsgChanges = new DatasetChangesCounter() ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgChanges) ;
+        ChangesCounter dsgChanges = new ChangesCounter() ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgChanges) ;
 
         check(dsgChanges, 0, 0, 0, 0) ;
         dsg.add(quad1) ;
@@ -76,9 +79,9 @@ public class TestDatasetMonitor
 
     @Test public void countChanges_04() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCounter dsgChanges = new DatasetChangesCounter() ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgChanges) ;
-        
+        ChangesCounter dsgChanges = new ChangesCounter() ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgChanges) ;
+
         check(dsgChanges, 0, 0, 0, 0) ;
         dsg.add(quad1) ;
         dsg.delete(quad1) ;
@@ -89,8 +92,8 @@ public class TestDatasetMonitor
 
     @Test public void countChanges_05() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCounter dsgChanges = new DatasetChangesCounter() ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgChanges) ;
+        ChangesCounter dsgChanges = new ChangesCounter() ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgChanges) ;
 
         check(dsgChanges, 0, 0, 0, 0) ;
         Graph g = dsg.getDefaultGraph();
@@ -103,8 +106,8 @@ public class TestDatasetMonitor
 
     @Test public void countChanges_06() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCounter dsgChanges = new DatasetChangesCounter() ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgChanges) ;
+        ChangesCounter dsgChanges = new ChangesCounter() ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgChanges) ;
 
         check(dsgChanges, 0, 0, 0, 0) ;
         Graph g = dsg.getGraph(NodeFactory.createURI("http://example.com/g1"));
@@ -117,8 +120,8 @@ public class TestDatasetMonitor
 
     @Test public void countChanges_07() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCounter dsgChanges = new DatasetChangesCounter() ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgChanges) ;
+        ChangesCounter dsgChanges = new ChangesCounter() ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgChanges) ;
 
         check(dsgChanges, 0, 0, 0, 0) ;
         Graph g = dsg.getDefaultGraph();
@@ -129,8 +132,8 @@ public class TestDatasetMonitor
 
     @Test public void countChanges_08() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCounter dsgChanges = new DatasetChangesCounter() ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgChanges) ;
+        ChangesCounter dsgChanges = new ChangesCounter() ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgChanges) ;
 
         check(dsgChanges, 0, 0, 0, 0) ;
         Graph g = dsg.getDefaultGraph();
@@ -141,43 +144,43 @@ public class TestDatasetMonitor
 
     @Test public void captureChanges_01() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCapture dsgCapture = new DatasetChangesCapture() ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgCapture) ;
-        
+        ChangesCapture dsgCapture = new ChangesCapture() ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgCapture) ;
+
         dsg.add(quad1) ;
         dsg.delete(quad1) ;
         dsg.add(quad2) ;
         dsg.add(quad2) ;
-        
-        List<Pair<QuadAction, Quad>> record = dsgCapture.getActions()  ;
+
+        List<Pair<TextQuadAction, Quad>> record = dsgCapture.getActions()  ;
         // Records only real actions.
         assertEquals(3, record.size()) ;
-        check(record, 0, ADD, quad1) ; 
+        check(record, 0, ADD, quad1) ;
         check(record, 1, DELETE, quad1) ;
         check(record, 2, ADD, quad2) ;
     }
 
     @Test public void captureChanges_02() {
         DatasetGraph dsgBase = DatasetGraphFactory.create() ;
-        DatasetChangesCapture dsgCapture = new DatasetChangesCapture(true) ;
-        DatasetGraph dsg = new DatasetGraphMonitor(dsgBase, dsgCapture) ;
-        
+        ChangesCapture dsgCapture = new ChangesCapture(true) ;
+        DatasetGraph dsg = new DatasetGraphTextMonitor(dsgBase, dsgCapture) ;
+
         dsg.add(quad1) ;
         dsg.delete(quad1) ;
         dsg.delete(quad1) ;
         dsg.add(quad2) ;
         dsg.add(quad2) ;
-        
-        List<Pair<QuadAction, Quad>> record = dsgCapture.getActions()  ;
+
+        List<Pair<TextQuadAction, Quad>> record = dsgCapture.getActions()  ;
         assertEquals(5, record.size()) ;
-        check(record, 0, ADD, quad1) ; 
+        check(record, 0, ADD, quad1) ;
         check(record, 1, DELETE, quad1) ;
         check(record, 2, NO_DELETE, quad1) ;
         check(record, 3, ADD, quad2) ;
         check(record, 4, NO_ADD, quad2) ;
     }
 
-    private static void check(DatasetChangesCounter changes, long adds, long deletes, long noAdds, long noDeletes)
+    private static void check(ChangesCounter changes, long adds, long deletes, long noAdds, long noDeletes)
     {
         assertEquals("Adds",        adds, changes.countAdd) ;
         assertEquals("Deletes",     deletes, changes.countDelete) ;
@@ -185,10 +188,10 @@ public class TestDatasetMonitor
         assertEquals("NoDeletes",   noDeletes, changes.countNoDelete) ;
     }
 
-    private static void check(List<Pair<QuadAction, Quad>> record, int indx, QuadAction quadAction, Quad quad)
+    private static void check(List<Pair<TextQuadAction, Quad>> record, int indx, TextQuadAction quadAction, Quad quad)
     {
         assertTrue("Index "+indx+" out of range [0,"+record.size()+")", 0 <= indx && indx < record.size() ) ;
-        Pair<QuadAction, Quad> pair = record.get(indx) ;
+        Pair<TextQuadAction, Quad> pair = record.get(indx) ;
         assertEquals(quadAction, pair.getLeft()) ;
         assertEquals(quad, pair.getRight()) ;
     }