You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2017/07/18 17:23:49 UTC

svn commit: r1802320 - /uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java

Author: schor
Date: Tue Jul 18 17:23:48 2017
New Revision: 1802320

URL: http://svn.apache.org/viewvc?rev=1802320&view=rev
Log:
[UIMA-5497] fixes for copy on write, also have common api methods return most specific impl class

Modified:
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java?rev=1802320&r1=1802319&r2=1802320&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java Tue Jul 18 17:23:48 2017
@@ -35,8 +35,12 @@ import org.apache.uima.jcas.cas.TOP;
 
 /**
  * The common (among all index kinds - set, sorted, bag) info for an index over 1 type (excluding subtypes)
- *   The name "Leaf" is a misnomer - it's just over one type excluding any subtypes if they exist
- * SubClasses define the actual index repository for each kind.
+ *   
+ * SubClasses 
+ *   FsIndex_bag, 
+ *   FsIndex_flat, 
+ *   FsIndex_set_sorted, 
+ * define the actual index repository for each kind.
  * 
  * @param <T> the Java cover class type for this index, passed along to (wrapped) iterators producing Java cover classes
  */
@@ -181,15 +185,18 @@ public abstract class FsIndex_singletype
   /**
    * Common part of iterator creation
    */
-  protected void setupIteratorCopyOnWrite() {
+  protected CopyOnWriteIndexPart setupIteratorCopyOnWrite() {
+    CopyOnWriteIndexPart cow_index_part = getCopyOnWriteIndexPart();
     if (null == wr_cow || null == wr_cow.get()) {
-      wr_cow = new WeakReference<>(createCopyOnWriteIndexPart());
+      cow_index_part = createCopyOnWriteIndexPart();
+      wr_cow = new WeakReference<>(cow_index_part);  
     }
+    return cow_index_part;
   }
   
   @Override
-  public FSIterator<T> iterator(FeatureStructure initialPositionFs) {
-    FSIterator<T> fsIt = iterator();
+  public LowLevelIterator<T> iterator(FeatureStructure initialPositionFs) {
+    LowLevelIterator<T> fsIt = iterator();
     fsIt.moveTo(initialPositionFs);
     return fsIt;
   }
@@ -208,6 +215,9 @@ public abstract class FsIndex_singletype
     return this.indexType;
   }
 
+  @Override
+  abstract public LowLevelIterator<T> iterator();
+  
   /**
    * @param fs1 -
    * @param fs2 -
@@ -415,14 +425,12 @@ public abstract class FsIndex_singletype
     return n;
   }
   
-  protected CopyOnWriteIndexPart getCopyOnWriteIndexPart() {
-    if (wr_cow != null) {
-      CopyOnWriteIndexPart n = wr_cow.get();
-      if (n != null) {
-        return n;
-      }
-    }
-    return null;
+  /**
+   * @return the copy-on-write wrapper for an index part if it exists for this index, 
+   *           or null
+   */
+  public CopyOnWriteIndexPart getCopyOnWriteIndexPart() {
+    return (wr_cow == null) ? null : wr_cow.get();
   }
   
   protected abstract CopyOnWriteIndexPart createCopyOnWriteIndexPart();