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/10/05 19:22:17 UTC

svn commit: r1811237 - in /uima/uv3/uimaj-v3/trunk/uimaj-core/src: main/java/org/apache/uima/cas/ main/java/org/apache/uima/cas/impl/ main/java/org/apache/uima/internal/util/ main/java/org/apache/uima/jcas/ main/java/org/apache/uima/util/ test/java/org...

Author: schor
Date: Thu Oct  5 19:22:16 2017
New Revision: 1811237

URL: http://svn.apache.org/viewvc?rev=1811237&view=rev
Log:
[UIMA-5603] add and use new getIndexedFSs method

Modified:
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndexRepository.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AllFSs.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CasSerializerSupport.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CopyOnWriteIndexPart.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASSerializer.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteObjHashSet.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteOrderedFsSet_array.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GetAllIndexedTest.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTest.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsTest.java

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java Thu Oct  5 19:22:16 2017
@@ -20,6 +20,7 @@
 package org.apache.uima.cas;
 
 import java.io.InputStream;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.ListIterator;
 
@@ -1298,7 +1299,7 @@ public interface CAS extends AbstractCas
   }
   
   /**
-   * Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its
+   * Gets an iterator over all indexed (in this CAS view) FeatureStructures of the specified Type (and any of its
    * subtypes).  The elements are returned in arbitrary order, and duplicates (if they exist)
    * are not removed.
    *
@@ -1309,7 +1310,61 @@ public interface CAS extends AbstractCas
    *    corresponding to the JCas clazz, in no particular order.
    */
   default <T extends TOP> FSIterator<T> getAllIndexedFS(Class<T> clazz) {
-    return this.getIndexRepository().getAllIndexedFS(getCasType(clazz));
+    return getAllIndexedFS(getCasType(clazz));
+  }
+  
+  /**
+   * Gets an iterator over all indexed (in this CAS view) FeatureStructures of the specified Type (and any of its
+   * subtypes).  The elements are returned in arbitrary order, and duplicates (if they exist)
+   * are not removed.
+   *
+   * @param clazz - the JCas Java class specifing which type and subtypes are included
+   * @param <T> the Java clazz
+   *  
+   * @return An iterator that returns all indexed FeatureStructures of the Type and its subtypes, 
+   *    corresponding to the JCas clazz, in no particular order.
+   */
+  default <T extends TOP> FSIterator<T> getAllIndexedFS(Type type) {
+    return this.getIndexRepository().getAllIndexedFS(type);
+  }
+
+  /**
+   * Returns an unmodifiable collection of all the FSs that are indexed in this view, in an arbitrary order.  
+   * Subsequent modifications to the indexes do not affect this collection.
+   * @param type the type of Feature Structures to include (including subtypes)
+   * @param <T> The Java class associated with type
+   * @return an unmodifiable, unordered collection of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  default <T extends TOP> Collection<T> getIndexedFSs(Type type) {
+    return this.getIndexRepository().getIndexedFSs(type);
+  }
+  
+  /**
+   * Returns an unmodifiable collection of all of the FSs
+   * that are indexed in this view, in an arbitrary order.  
+   * Subsequent modifications to the indexes do not affect this collection.
+   * @param clazz
+   *          The JCas class corresponding to the type
+   * @param <T> The Java class associated with type
+   * @return an unmodifiable, unordered collection of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  default Collection<TOP> getIndexedFSs() { 
+    return this.getIndexRepository().getIndexedFSs();
   }
 
+  
+  /**
+   * Returns a collection of all the FSs that are indexed in this view, in an arbitrary order.  
+   * Subsequent modifications to the indexes do not affect this collection.
+   * @param clazz
+   *          The JCas class corresponding to the type
+   * @param <T> The Java class associated with type
+   * @return an unmodifiable, unordered collection of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  default <T extends TOP> Collection<T> getIndexedFSs(Class<T> clazz) {
+    return this.getIndexRepository().getIndexedFSs(clazz);
+  }
 }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndexRepository.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndexRepository.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndexRepository.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndexRepository.java Thu Oct  5 19:22:16 2017
@@ -19,6 +19,7 @@
 
 package org.apache.uima.cas;
 
+import java.util.Collection;
 import java.util.Iterator;
 
 import org.apache.uima.cas.impl.FSIndexRepositoryImpl;
@@ -152,7 +153,7 @@ public interface FSIndexRepository {
   }
 
   /**
-   * Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its
+   * Gets an iterator over all indexed (in this View) FeatureStructures of the specified Type (and any of its
    * subtypes).  The elements are returned in arbitrary order.
    *
    * Generics: T is the Java class for aType.
@@ -165,7 +166,7 @@ public interface FSIndexRepository {
   <T extends FeatureStructure> FSIterator<T> getAllIndexedFS(Type aType);
   
   /**
-   * Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its
+   * Gets an FSIterator over all indexed (in this view) FeatureStructures of the specified Type (and any of its
    * subtypes).  The elements are returned in arbitrary order.
    *
    * Generics: T is the Java class for aType.
@@ -176,8 +177,42 @@ public interface FSIndexRepository {
    *         and its subtypes, in no particular order.
    */
   default <T extends FeatureStructure> FSIterator<T> getAllIndexedFS(Class<T> clazz) {
-    return getAllIndexedFS(((FSIndexRepositoryImpl)this).getCasImpl().getJCasImpl().getCasType(clazz));
+    return getAllIndexedFS(((FSIndexRepositoryImpl)this).getCasImpl().getCasType((Class<TOP>) clazz));
   }
   
+  /**
+   * Returns an unmodifiable collection of all the FSs of this type and its subtypes, 
+   * that are indexed in this view, in an arbitrary order.  
+   * Subsequent modifications to the indexes do not affect this collection.
+   * @param type the type of Feature Structures to include (including subtypes)
+   * @param <T> The Java class associated with type
+   * @return an unmodifiable, unordered collection of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  public <T extends TOP> Collection<T> getIndexedFSs(Type type);
   
+  /**
+   * Returns an unmodifiable collection of all the FSs of this type and its subtypes, 
+   * that are indexed in this view, in an arbitrary order.  
+   * Subsequent modifications to the indexes do not affect this collection.
+   * @param clazz
+   *          The JCas class corresponding to the type
+   * @param <T> The Java class associated with type
+   * @return an unmodifiable, unordered collection of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  public <T extends TOP> Collection<T> getIndexedFSs(Class<T> clazz);
+ 
+  /**
+   * Returns an unmodifiable collection of all of the FSs
+   * that are indexed in this view, in an arbitrary order.  
+   * Subsequent modifications to the indexes do not affect this collection.
+   * @param clazz
+   *          The JCas class corresponding to the type
+   * @param <T> The Java class associated with type
+   * @return an unmodifiable, unordered collection of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  public <T extends TOP> Collection<T> getIndexedFSs();
+
 }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AllFSs.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AllFSs.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AllFSs.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AllFSs.java Thu Oct  5 19:22:16 2017
@@ -20,6 +20,7 @@
 package org.apache.uima.cas.impl;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
@@ -85,8 +86,7 @@ class AllFSs {
 
   public AllFSs getAllFSsAllViews_sofas() {
     cas.forAllSofas(sofa -> enqueueFS(sofa));
-    cas.forAllViews(view -> 
-       getFSsForView(view.indexRepository.<TOP>getAllIndexedFS(cas.getTypeSystemImpl().topType).stream()));
+    cas.forAllViews(view -> getFSsForView(view.indexRepository.getIndexedFSs()));
     return this;
   }
 
@@ -111,8 +111,10 @@ class AllFSs {
     return this;
   }
   
-  private void getFSsForView(Stream<TOP> fss) {
-    fss.forEach(fs -> enqueueFS(fs));
+  private void getFSsForView(Collection<TOP> fss) {
+    for (TOP fs : fss) {
+      enqueueFS(fs);
+    }
   }
   
   private void enqueueFS(TOP fs) {

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java Thu Oct  5 19:22:16 2017
@@ -1240,7 +1240,7 @@ public class BinaryCasSerDes {
   // etc.
   int[] getIndexedFSs(Obj2IntIdentityHashMap<TOP> fs2addr) {
     IntVector v = new IntVector();
-    List<TOP> fss;
+    Collection<TOP> fss;
 
     int numViews = baseCas.getViewCount();
     v.add(numViews);
@@ -1252,7 +1252,7 @@ public class BinaryCasSerDes {
 
     // Get indexes for each view in the CAS
     baseCas.forAllViews(view -> 
-        addIdsToIntVector(view.indexRepository.getIndexedFSs(), v, fs2addr));
+        addIdsToIntVector(view.getIndexedFSs(), v, fs2addr));
     return v.toArray();
   }
 

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java Thu Oct  5 19:22:16 2017
@@ -2854,7 +2854,7 @@ public class BinaryCasSerDes6 implements
       processFSsForView(true,  // is enqueue
         isSerializingDelta 
           ? view.indexRepository.getAddedFSs().stream()
-          : view.indexRepository.<TOP>getAllIndexedFS(topType).stream());
+          : view.indexRepository.<TOP>getIndexedFSs(topType).stream());
       if (isSerializingDelta) {
         // for write/delta, write out (but don't enqueue) the deleted/reindexed FSs
         processFSsForView(false, view.indexRepository.getDeletedFSs().stream());

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CasSerializerSupport.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CasSerializerSupport.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CasSerializerSupport.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CasSerializerSupport.java Thu Oct  5 19:22:16 2017
@@ -555,14 +555,14 @@ public class CasSerializerSupport {
         final Sofa sofa = getSofa(sofaNum);
         if (loopIR != null) {
           if (!isDelta) {
-            Collection<TOP> fsarray = loopIR.getIndexedFSs();
-            csss.writeView(sofa, fsarray);
+            Collection<TOP> fss = loopIR.getIndexedFSs();
+            csss.writeView(sofa, fss);
           } else { // is Delta Cas
         	  if (sofaNum != 1 && this.marker.isNew(sofa)) {
         	    // for views created after mark (initial view never is - it is always created with the CAS)
         	    // write out the view as new
-        	    List<TOP> fsarray = loopIR.getIndexedFSs();
-              csss.writeView(sofa, fsarray);
+        	    Collection<TOP> fss = loopIR.getIndexedFSs();
+              csss.writeView(sofa, fss);
         	  } else if (loopIR.isModified()) {
         	    csss.writeView(sofa, loopIR.getAddedFSs(), loopIR.getDeletedFSs(), loopIR.getReindexedFSs());
           	}
@@ -659,7 +659,7 @@ public class CasSerializerSupport {
      */
     private void enqueueIndexed()  {
       FSIndexRepositoryImpl ir = (FSIndexRepositoryImpl) cas.getBaseCAS().getBaseIndexRepository();
-      List<TOP> fss = ir.getIndexedFSs();  // only sofas
+      Collection<TOP> fss = ir.getIndexedFSs();  // only sofas
       try {
         for (TOP fs : fss) {
           enqueueFsAndMaybeFeatures(fs);  // put Sofa on by-ref queue
@@ -680,7 +680,7 @@ public class CasSerializerSupport {
         FSIndexRepositoryImpl loopIR = (FSIndexRepositoryImpl) cas.getBaseCAS()
                 .getSofaIndexRepository(sofaNum);
         if (loopIR != null) {
-          List<TOP> items = loopIR.getIndexedFSs();
+          Collection<TOP> items = loopIR.getIndexedFSs();
           for (TOP item : items) {
             enqueueIndexedFs_only_not_features(sofaNum, item);
           }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CopyOnWriteIndexPart.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CopyOnWriteIndexPart.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CopyOnWriteIndexPart.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CopyOnWriteIndexPart.java Thu Oct  5 19:22:16 2017
@@ -19,10 +19,14 @@
 
 package org.apache.uima.cas.impl;
 
+import java.util.Iterator;
+
+import org.apache.uima.jcas.cas.TOP;
+
 /**
  * common APIs supporting the copy on write aspect of index parts
  */
-public interface CopyOnWriteIndexPart {
+public interface CopyOnWriteIndexPart<T> {
   
   void makeReadOnlyCopy();
   
@@ -31,4 +35,22 @@ public interface CopyOnWriteIndexPart {
    *              true means the index has not been updated
    */
   boolean isOriginal();
+  
+  /**
+   * @return The number of elements in the index
+   */
+  int size();
+  
+  /**
+   * @return iterator over all the elements
+   */
+  Iterator<T> iterator();
+  
+  /**
+   * Copy FS refs to target from this index part
+   * @param target the target array to copy into
+   * @param startingIndexInTarget the starting index in the target array
+   * @return startingIndexInTarget + size
+   */
+  int copyToArray(TOP[] target, int startingIndexInTarget);
 }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java Thu Oct  5 19:22:16 2017
@@ -19,8 +19,10 @@
 
 package org.apache.uima.cas.impl;
 
+import java.util.AbstractCollection;
 import java.util.ArrayList;
 import java.util.BitSet;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -28,6 +30,7 @@ import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.function.Consumer;
 import java.util.stream.Stream;
@@ -1088,36 +1091,36 @@ public class FSIndexRepositoryImpl imple
   // ///////////////////////////////////////////////////////////////////////////
   // Serialization support
 
-  /**
-   * For one particular view (the one associated with this instance of FsIndexRepositoryImpl),
-   * return an array containing all FSs in any defined index, in this view. 
-   * This is intended to be used for serialization.
-   * 
-   * The order in which FSs occur in the array does not reflect the order in which they
-   * were added to the repository. 
-   * 
-   * @param <T> type of Feature Structure
-   * @return a List of all FSs in any defined index, in this view.
-   */
-  public <T extends FeatureStructure> List<T> getIndexedFSs() {
-    
-    final ArrayList<TOP> v = new ArrayList<>();  // accumulates fsAddrs from various indexes
-    
-    /* Iterate over index by type, with something in there
-     * and dump all the fss found for that type (excluding subtypes) into v
-     *   bag preferred over sorted; 
-     */
-    for (int i = 0; i < this.usedIndexes.size(); i++) {
-//      // debug
-//      int vs1 = v.size();
-      getNonSetSingleIndexForUsedType(i).bulkAddTo(v);
-//      for (int di = vs1; di < v.size(); di ++) {  // debug
-//        assert v.get(di) != null;                 // debug verify not null
-//      }
-    }  
-   
-    return (List<T>) v;
-  }
+//  /**
+//   * For one particular view (the one associated with this instance of FsIndexRepositoryImpl),
+//   * return an array containing all FSs in any defined index, in this view. 
+//   * This is intended to be used for serialization.
+//   * 
+//   * The order in which FSs occur in the array does not reflect the order in which they
+//   * were added to the repository. 
+//   * 
+//   * @param <T> type of Feature Structure
+//   * @return a List of all FSs in any defined index, in this view.
+//   */
+//  public <T extends FeatureStructure> List<T> getIndexedFSs4Serializers() {
+//    
+//    final ArrayList<TOP> v = new ArrayList<>();  // accumulates fsAddrs from various indexes
+//    
+//    /* Iterate over index by type, with something in there
+//     * and dump all the fss found for that type (excluding subtypes) into v
+//     *   bag preferred over sorted; 
+//     */
+//    for (int i = 0; i < this.usedIndexes.size(); i++) {
+////      // debug
+////      int vs1 = v.size();
+//      getNonSetSingleIndexForUsedType(i).bulkAddTo(v);
+////      for (int di = vs1; di < v.size(); di ++) {  // debug
+////        assert v.get(di) != null;                 // debug verify not null
+////      }
+//    }  
+//   
+//    return (List<T>) v;
+//  }
   
   /**
    * For this view, walk the indexed FSs in arbitrary order.
@@ -1451,26 +1454,8 @@ public class FSIndexRepositoryImpl imple
    */
   public <T extends FeatureStructure> LowLevelIterator<T> getAllIndexedFS(Type type) {
     final ArrayList<LowLevelIterator<T>> iteratorList = new ArrayList<>();
-    
-//    TypeImpl ti = (TypeImpl) type;
-//    if (!isUsedChanged && ti.isTopType()) {  
-//      // reuse previously computed iicps4allFSs
-//      for (FsIndex_iicp<?> iicp : iicps4allFSs) {
-//        if (iicp.cachedSubFsLeafIndexes[0].size() != 0) {
-//          LowLevelIterator<T> it = (iicp.getIndexingStrategy() == FSIndex.SORTED_INDEX) 
-//              ? (LowLevelIterator<T>)iicp.iteratorUnordered()
-//              : (LowLevelIterator<T>)iicp.iterator();
-//          iteratorList.add(it);
-//        }
-//      }
-//    } else {
-//      iicps4allFSs.clear();
-    
-      getAllIndexedFS(type, iteratorList);
-      
-//      this.isUsedChanged = false; // above call recomputed the cache  
-//    }    
 
+    getAllIndexedFS(type, iteratorList);
     
     final int iteratorListSize = iteratorList.size();
     if (iteratorListSize == 0) {
@@ -1535,7 +1520,141 @@ public class FSIndexRepositoryImpl imple
 //    ((TypeImpl)type).getDirectSubtypes().stream().forEach(subType -> getAllIndexedFS(subType, iteratorList));
   }
 
+  public Collection<TOP> getIndexedFSs() {
+    return getIndexedFSs(sii.tsi.topType);
+  }
   
+  public <T extends TOP> Collection<T> getIndexedFSs(Class<T> clazz) {
+    return getIndexedFSs(cas.getCasType(clazz));
+  }
+  
+  /**
+   * @param type the type of Feature Structures to include (including subtypes)
+   * @return an unmodifiable, unordered set of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  public <T extends TOP> Collection<T> getIndexedFSs(Type type) {
+    // collect CopyOnWriteIndexPart s for all index parts for type and its subtypes
+    final ArrayList<CopyOnWriteIndexPart<T>> indexes = new ArrayList<>(); 
+    TypeImpl ti = (TypeImpl) type;
+    
+    collectCowIndexParts(ti, indexes);
+    
+    if (indexes.size() == 0) {
+      return Collections.emptySet();
+    }
+
+    return new AbstractCollection<T>() {
+      
+      @Override
+      public Iterator<T> iterator() {
+        return new Iterator<T>() {
+          final int indexesSize = indexes.size();
+          int indexesIndex = 0;
+          Iterator<T> it = indexes.get(0).iterator();
+          
+          @Override
+          public boolean hasNext() {
+            return indexesIndex < indexesSize; 
+          }
+
+          @Override
+          public T next() {
+            if (!hasNext()) {
+              throw new NoSuchElementException();
+            }
+            T v = it.next();
+            
+            if (!it.hasNext()) {
+              indexesIndex++;
+              if (indexesIndex == indexesSize) {
+                return v;
+              }
+              it = indexes.get(indexesIndex).iterator();
+            }
+            return v;
+          }
+          
+        };
+      }
+
+      @Override
+      public int size() {
+        int r = 0;
+        for (CopyOnWriteIndexPart<T> cow : indexes) {
+          r += cow.size();
+        }
+        return r;
+      }
+      
+      @Override
+      public TOP[] toArray() {
+        TOP[] r = new TOP[size()];
+        
+        int i = 0;
+        for (CopyOnWriteIndexPart<T> idx : indexes) {
+          i = idx.copyToArray(r, i);
+        }
+        return r;
+      }
+
+      /* (non-Javadoc)
+       * @see java.util.AbstractCollection#toArray(java.lang.Object[])
+       */
+      @Override
+      public <U> U[] toArray(U[] r) {
+        
+        int i = 0;
+        for (CopyOnWriteIndexPart<T> idx : indexes) {
+          i = idx.copyToArray((TOP[]) r, i);
+        }
+        return r;
+      }
+
+      
+      
+      /* (non-Javadoc)
+       * @see java.util.AbstractCollection#isEmpty()
+       */
+      @Override
+      public boolean isEmpty() {
+        return indexes.isEmpty();
+      }
+      
+    };
+  }
+  
+  private <T extends TOP> void collectCowIndexParts(TypeImpl ti, ArrayList<CopyOnWriteIndexPart<T>> indexes) {
+    FsIndex_iicp<T> iicp;
+    
+    if (!isUsed.get(ti.getCode()) ||
+        (iicp = getIndexesForType(ti.getCode()).getNonSetIndex()) == null  || 
+        iicp.isEmpty()) {  // could be used, but now empty
+      // No index for this type was found at all. 
+      // Example:  You ask for an iterator over "TOP", but no instances of TOP are created,
+      //   and no index over TOP was ever created.
+      // Since the auto-indexes are created on demand for
+      //   each type, there may be gaps in the inheritance chain. So keep descending the inheritance
+      //   tree looking for relevant indexes.
+      ti.getDirectSubtypes().forEach(type -> collectCowIndexParts(type, indexes));
+      return;
+    }
+    
+    if (iicp.isDefaultBagIndex()) {
+      if (iicp.getFsIndex_singleType().size() > 0) {
+        indexes.add(iicp.getFsIndex_singleType().getNonNullCow());
+      }
+      ti.getDirectSubtypes().forEach(type -> collectCowIndexParts(type, indexes));
+    } else {
+      iicp.collectCowIndexParts(indexes);
+    }
+  }
+  
+  /**
+   * Stream instances of all of the non-empty indexes themselves
+   * @param type - the type to filter the indexes with
+   * @return all of the non-empty indexes, one for each sorted or default bag per type
+   */
   public Stream<FsIndex_singletype<TOP>> streamNonEmptyIndexes(Type type) {
     TypeImpl ti = (TypeImpl) type;
     if (!isUsed.get(ti.getCode())) {
@@ -1552,10 +1671,10 @@ public class FSIndexRepositoryImpl imple
   }
   
   public Stream<FsIndex_singletype<TOP>> streamNonEmptyIndexes(Class<? extends TOP> clazz) {
-    return streamNonEmptyIndexes(((FSIndexRepositoryImpl)this).getCasImpl().getJCasImpl().getCasType(clazz));
+    return streamNonEmptyIndexes(getCasImpl().getCasType(clazz));
   }
     
-  public Stream<FsIndex_singletype<TOP>> streamNonEmptyDirectSubtypes(TypeImpl ti) {
+  private Stream<FsIndex_singletype<TOP>> streamNonEmptyDirectSubtypes(TypeImpl ti) {
     Stream<FsIndex_singletype<TOP>> r = null;
     for (TypeImpl subType : ti.getDirectSubtypes()) {
       r = (r == null) 

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java Thu Oct  5 19:22:16 2017
@@ -563,6 +563,15 @@ class FsIndex_iicp<T extends FeatureStru
     return Arrays.stream(cachedSubFsLeafIndexes).filter(idx -> idx.size() > 0);
   }
   
+  void collectCowIndexParts(ArrayList<CopyOnWriteIndexPart<T>> indexes) {
+    createIndexIteratorCache();
+    for (FsIndex_singletype idx : cachedSubFsLeafIndexes) {
+      if (idx.size() > 0) {
+        indexes.add(idx.getNonNullCow());
+      }
+    }
+  }
+  
   LowLevelIterator<T>[] getIterators() {
     createIndexIteratorCache();
     LowLevelIterator<T>[] r = new LowLevelIterator[cachedSubFsLeafIndexes.length];

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=1811237&r1=1811236&r2=1811237&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 Thu Oct  5 19:22:16 2017
@@ -117,7 +117,7 @@ public abstract class FsIndex_singletype
    * Weak ref so that after iterator is GC'd, and no ref's exist, this becomes
    * null, so that future mods no longer need to do extra work.
    */
-  protected WeakReference<CopyOnWriteIndexPart> wr_cow = null;
+  protected WeakReference<CopyOnWriteIndexPart<T>> wr_cow = null;
 
   @Override
   public String toString() {
@@ -542,7 +542,7 @@ public abstract class FsIndex_singletype
    * @return the copy-on-write wrapper for an index part if it exists for this
    *         index, or null
    */
-  public CopyOnWriteIndexPart getCopyOnWriteIndexPart() {
+  public CopyOnWriteIndexPart<T> getCopyOnWriteIndexPart() {
     return (wr_cow == null) ? null : wr_cow.get();
   }
 

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASSerializer.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASSerializer.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASSerializer.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XCASSerializer.java Thu Oct  5 19:22:16 2017
@@ -23,7 +23,8 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
-import java.util.Collections;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Deque;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
@@ -47,6 +48,7 @@ import org.apache.uima.jcas.cas.FloatArr
 import org.apache.uima.jcas.cas.IntegerArray;
 import org.apache.uima.jcas.cas.LongArray;
 import org.apache.uima.jcas.cas.ShortArray;
+import org.apache.uima.jcas.cas.Sofa;
 import org.apache.uima.jcas.cas.StringArray;
 import org.apache.uima.jcas.cas.TOP;
 import org.apache.uima.util.XMLSerializer;
@@ -347,27 +349,39 @@ public class XCASSerializer {
      * Push the indexed FSs onto the queue.
      */
     private void enqueueIndexed() {
-      List<TOP> allSofas = cas.getBaseIndexRepositoryImpl().getIndexedFSs();
-      
-      // XCAS requires sofas in order of id
-      Collections.sort(allSofas, (fs1, fs2) -> Integer.compare(fs1._id, fs2._id) );
-      enqueueList(allSofas, 0);
-      
+      Collection<Sofa> sofaCollection = cas.getBaseIndexRepositoryImpl().<Sofa>getIndexedFSs(Sofa.class);
+      int sofaCount = sofaCollection.size();
+      if (sofaCount > 0) {
+        Sofa[] allSofas = sofaCollection.toArray(new Sofa[sofaCount]);
+        
+        // XCAS requires sofas in order of id
+        Arrays.sort(allSofas, (fs1, fs2) -> Integer.compare(fs1._id, fs2._id) );
+        enqueueArray(allSofas, 0);
+      }
 
       // Get indexes for each SofaFS in the CAS
       for (int sofaNum = 1, numViews = cas.getViewCount(); sofaNum <= numViews; sofaNum++) {
         FSIndexRepositoryImpl viewIR = (FSIndexRepositoryImpl) cas.getBaseCAS().getSofaIndexRepository(sofaNum);
         if (viewIR != null) {
-          enqueueList(viewIR.getIndexedFSs(), sofaNum);
+          Collection<TOP> fssInView = viewIR.getIndexedFSs();
+          if (! fssInView.isEmpty()) {
+            enqueueCollection(fssInView, sofaNum);
+          }
         }
       }
     }
     
-    private void enqueueList(List<TOP> fss, int sofaNum) {
+    private void enqueueArray(TOP[] fss, int sofaNum) {
       for (TOP fs : fss) {   // enqueues the fss for one view (incl view 0 - the base view
         enqueueIndexed(fs, sofaNum);
       }
     }
+    
+    private void enqueueCollection(Collection<TOP> fss, int sofaNum) {
+      for (TOP fs : fss) {
+        enqueueIndexed(fs, sofaNum);
+      }
+    }
 
     private void enqueueFeaturesOfIndexed() {
       final int max = indexedFSs.size();

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteObjHashSet.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteObjHashSet.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteObjHashSet.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteObjHashSet.java Thu Oct  5 19:22:16 2017
@@ -24,6 +24,7 @@ import java.util.NoSuchElementException;
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.impl.CopyOnWriteIndexPart;
 import org.apache.uima.internal.util.ObjHashSet;
+import org.apache.uima.jcas.cas.TOP;
 
 /**
  * implements ObjHashSet partially, for iterator use
@@ -183,5 +184,18 @@ public class CopyOnWriteObjHashSet<T> im
     return ohs == original;
   }
 
+  /* (non-Javadoc)
+   * @see org.apache.uima.cas.impl.CopyOnWriteIndexPart#copyToArray(org.apache.uima.jcas.cas.TOP[], int)
+   */
+  @Override
+  public int copyToArray(TOP[] target, int startingIndexInTarget) {
+    Iterator<T> it = iterator();
+    int i = startingIndexInTarget;
+    while (it.hasNext()) {
+      target[i++] = (TOP) it.next();
+    }
+    return i;
+  }
+
   
 }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteOrderedFsSet_array.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteOrderedFsSet_array.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteOrderedFsSet_array.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/CopyOnWriteOrderedFsSet_array.java Thu Oct  5 19:22:16 2017
@@ -18,6 +18,9 @@
  */
 package org.apache.uima.internal.util;
 
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
 import org.apache.uima.cas.impl.CopyOnWriteIndexPart;
 import org.apache.uima.jcas.cas.TOP;
 
@@ -87,7 +90,7 @@ public class CopyOnWriteOrderedFsSet_arr
    * @return the size of this version of the index (maybe not the current index size)
    */
   public int size() {
-    return set.size();
+    return a_nextFreeslot - a_firstUsedslot;
   }
 
 //  /**
@@ -108,5 +111,38 @@ public class CopyOnWriteOrderedFsSet_arr
   public OrderedFsSet_array<TOP> getOfsa() {
     return set;
   }
+  
+  /* (non-Javadoc)
+   * @see java.lang.Iterable#iterator()
+   */
+  @Override
+  public Iterator<TOP> iterator() {
+    return new Iterator<TOP>() {
+
+      int pos = a_firstUsedslot;
+      
+      @Override
+      public boolean hasNext() {
+        return pos >= 0 && pos < a_nextFreeslot;
+      }
+
+      @Override
+      public TOP next() {
+        if (!hasNext()) {
+          throw new NoSuchElementException();
+        }
+        return a[pos++];
+      }      
+    };
+  }
+
+  /* (non-Javadoc)
+   * @see org.apache.uima.cas.impl.CopyOnWriteIndexPart#copyToArray(org.apache.uima.jcas.cas.TOP[], int)
+   */
+  @Override
+  public int copyToArray(TOP[] target, int startingIndexInTarget) {
+    System.arraycopy(a, a_firstUsedslot, target, startingIndexInTarget, size());
+    return startingIndexInTarget + size();
+  }
 
 }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/JCas.java Thu Oct  5 19:22:16 2017
@@ -20,6 +20,7 @@
 package org.apache.uima.jcas;
 
 import java.io.InputStream;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.ListIterator;
 
@@ -797,6 +798,22 @@ public interface JCas extends AbstractCa
    * subtypes).  The elements are returned in arbitrary order, and duplicates (if they exist)
    * are not removed.
    *
+   * @param type - the type specifying which type and subtypes are included
+   * @param <T> the Java clazz of the returned types
+   *  
+   * @return An iterator that returns all indexed FeatureStructures of the JCas clazz 
+   *         and its subtypes, in no particular order.
+   */
+  default <T extends TOP> FSIterator<T> getAllIndexedFS(Type type) {
+    return getFSIndexRepository().getAllIndexedFS(type);
+  }
+
+  
+  /**
+   * Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its
+   * subtypes).  The elements are returned in arbitrary order, and duplicates (if they exist)
+   * are not removed.
+   *
    * @param clazz - the JCas Java class specifing which type and subtypes are included
    * @param <T> the Java clazz
    *  
@@ -805,8 +822,46 @@ public interface JCas extends AbstractCa
    */
   <T extends TOP> FSIterator<T> getAllIndexedFS(Class<T> clazz);
 
+  /**
+   * Returns an unmodifiable collection of all the FSs that are indexed in this view, in an arbitrary order.  
+   * Subsequent modifications to the indexes do not affect this collection.
+   * @param type the type of Feature Structures to include (including subtypes)
+   * @param <T> The Java class associated with type
+   * @return an unmodifiable, unordered collection of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  default <T extends TOP> Collection<T> getIndexedFSs(Type type) {
+    return this.getIndexRepository().getIndexedFSs(type);
+  }
   
   /**
+   * Returns an unmodifiable collection of all the FSs that are indexed in this view, in an arbitrary order.  
+   * Subsequent modifications to the indexes do not affect this collection.
+   * @param clazz
+   *          The JCas class corresponding to the type
+   * @param <T> The Java class associated with type
+   * @return an unmodifiable, unordered collection of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  default <T extends TOP> Collection<T> getIndexedFSs(Class<T> clazz) {
+    return this.getIndexRepository().getIndexedFSs(clazz);
+  }
+
+  /**
+   * Returns an unmodifiable collection of all of the FSs
+   * that are indexed in this view, in an arbitrary order.  
+   * Subsequent modifications to the indexes do not affect this collection.
+   * @param clazz
+   *          The JCas class corresponding to the type
+   * @param <T> The Java class associated with type
+   * @return an unmodifiable, unordered collection of all indexed (in this view) Feature Structures
+   *         of the specified type (including subtypes)
+   */
+  default Collection<TOP> getIndexedFSs() { 
+    return this.getIndexRepository().getIndexedFSs();
+  }
+
+  /**
    * Get iterator over all views in this JCas.  Each view provides access to Sofa data
    * and the index repository that contains metadata (annotations and other feature 
    * structures) pertaining to that Sofa.

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java Thu Oct  5 19:22:16 2017
@@ -19,6 +19,7 @@
 package org.apache.uima.util;
 
 import java.util.ArrayDeque;
+import java.util.Collection;
 import java.util.Deque;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
@@ -29,7 +30,6 @@ import org.apache.uima.UimaSerializable;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.CASRuntimeException;
 import org.apache.uima.cas.CommonArrayFS;
-import org.apache.uima.cas.FSIterator;
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.SofaFS;
 import org.apache.uima.cas.impl.CASImpl;
@@ -574,11 +574,10 @@ public class CasCopier {
       //   FSs when doing a full CAS copy with multiple views - the 2nd and subsequent
       //   views don't copy, but they do index.
       
-      FSIterator<TOP> it = srcCasViewImpl.getIndexRepository().getAllIndexedFS(srcTsi.getTopType());
+      Collection<TOP> c = srcCasViewImpl.getIndexRepository().getIndexedFSs();
   //    LowLevelIterator it = ((FSIndexRepositoryImpl)(srcCasViewImpl.getIndexRepository())).ll_getAllIndexedFS(srcTsi.getTopType());
   
-      while (it.hasNext()) {
-        final TOP fs = it.nextNvc();
+      for (final TOP fs : c) {
   //      System.out.format("debug  id: %,d  type: %s%n", fs.id(), fs._getTypeImpl().getShortName());
   //    Iterator<LowLevelIndex> indexes = srcCasViewImpl.getIndexRepository().ll_getIndexes();
   //    while (indexes.hasNext()) {

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/SerDesTest6.java Thu Oct  5 19:22:16 2017
@@ -32,6 +32,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -1600,10 +1601,10 @@ public class SerDesTest6 extends SerDesT
   }
 
   private List<FeatureStructure> getIndexedFSs(CASImpl cas, TTypeSystem m) {
-    FSIterator<FeatureStructure> it = cas.getIndexRepository().getAllIndexedFS(m.getType(Akof1));
+    Collection<TOP> c = cas.getIndexRepository().getIndexedFSs(m.getType(Akof1));
     List<FeatureStructure> lfs = new ArrayList<FeatureStructure>();
-    while (it.hasNext()) {
-      lfs.add(it.next());
+    for (TOP fs : c) {
+      lfs.add(fs);
     }
     return lfs;
   }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GetAllIndexedTest.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GetAllIndexedTest.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GetAllIndexedTest.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GetAllIndexedTest.java Thu Oct  5 19:22:16 2017
@@ -21,6 +21,7 @@ package org.apache.uima.cas.test;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Iterator;
 
 import org.apache.uima.UIMAFramework;
 import org.apache.uima.analysis_engine.AnalysisEngine;
@@ -29,6 +30,7 @@ import org.apache.uima.cas.FSIterator;
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.jcas.cas.TOP;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.apache.uima.resource.ResourceSpecifier;
 import org.apache.uima.test.junit_extension.JUnitExtension;
@@ -218,6 +220,8 @@ public class GetAllIndexedTest extends T
     assertNotNull(tokenType);
     FSIterator<FeatureStructure> tokenIter = this.cas.getIndexRepository().getAllIndexedFS(tokenType);
     assertFalse(tokenIter.hasNext());
+    Iterator<TOP> tokenIter2 = this.cas.getIndexedFSs(tokenType).iterator();
+    assertFalse( tokenIter2.hasNext());
   }
 
   public static void main(String[] args) {

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTest.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTest.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTest.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTest.java Thu Oct  5 19:22:16 2017
@@ -21,6 +21,7 @@ package org.apache.uima.cas.test;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Iterator;
 import java.util.Properties;
 
 import org.apache.uima.UIMAFramework;
@@ -269,7 +270,8 @@ public class GrowingTheCasTest extends T
 }
 
   private void timeIt(int i) {
-    FSIterator<FeatureStructure> it = jcas.getIndexRepository().getAllIndexedFS(jcas.getCasType(Annotation.type));   
+//    FSIterator<FeatureStructure> it = jcas.getIndexRepository().getAllIndexedFS(jcas.getCasType(Annotation.type));   
+    Iterator<Annotation> it = jcas.getIndexedFSs(Annotation.class).iterator();    
     int c = 0;
     long startTime = System.nanoTime();
     while (it.hasNext()) {

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas_data/impl/CasComparer.java Thu Oct  5 19:22:16 2017
@@ -20,6 +20,7 @@
 package org.apache.uima.cas_data.impl;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.ConcurrentModificationException;
@@ -127,8 +128,8 @@ public class CasComparer {
     
     // allow for different ordering in the getAllIndexedFSs
     
-    List<TOP> list1 = populate(c1.getIndexRepository().getAllIndexedFS(c1.getTypeSystem().getTopType()), alreadyCompared);
-    List<TOP> list2 = populate(c2.getIndexRepository().getAllIndexedFS(c2.getTypeSystem().getTopType()), alreadyCompared);
+    List<TOP> list1 = populate(c1.getIndexRepository().getIndexedFSs(), alreadyCompared);
+    List<TOP> list2 = populate(c2.getIndexRepository().getIndexedFSs(), alreadyCompared);
     
     Assert.assertEquals(list1.size(),  list2.size());
     
@@ -370,10 +371,9 @@ public class CasComparer {
   /* 
    * When populating, skip items already visted and compared in other views (but always include sofas)
    */
-  private static List<TOP> populate(FSIterator<TOP> it, Set<TOP> visited) {
+  private static List<TOP> populate(Collection<TOP> items, Set<TOP> visited) {
     List<TOP> s = new ArrayList<TOP>();
-    while (it.hasNext()) {
-      TOP fs = it.next();
+    for (TOP fs : items) {
       if (!(fs instanceof Sofa) && !visited.contains(fs)) {
         s.add(fs);
       }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasCopierTest.java Thu Oct  5 19:22:16 2017
@@ -304,7 +304,8 @@ public class CasCopierTest extends TestC
 
     CasComparer cci = new CasComparer();
     // copy all entities
-    Iterator<TOP> it = srcCas.getIndexRepository().getAllIndexedFS(srcCas.getTypeSystem().getType("org.apache.uima.testTypeSystem.Entity"));
+    Iterator<TOP> it = srcCas.getIndexRepository().getIndexedFSs(srcCas.getTypeSystem().getType("org.apache.uima.testTypeSystem.Entity")).iterator();
+//    Iterator<TOP> it = srcCas.getIndexRepository().getAllIndexedFS(srcCas.getTypeSystem().getType("org.apache.uima.testTypeSystem.Entity"));
 //    while(it.hasNext()) {
       TOP fs = it.next();
       TOP fsc = (TOP) copier.copyFs(fs);

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsTest.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsTest.java?rev=1811237&r1=1811236&r2=1811237&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsTest.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasIOUtilsTest.java Thu Oct  5 19:22:16 2017
@@ -28,21 +28,22 @@ import java.io.FileOutputStream;
 import java.io.ObjectOutput;
 import java.io.ObjectOutputStream;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.uima.UIMAFramework;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.CASRuntimeException;
-import org.apache.uima.cas.FSIterator;
-import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.SerialFormat;
+import org.apache.uima.jcas.cas.TOP;
 import org.apache.uima.resource.metadata.FsIndexDescription;
 import org.apache.uima.resource.metadata.TypeSystemDescription;
 import org.apache.uima.resource.metadata.impl.TypePriorities_impl;
 import org.apache.uima.test.junit_extension.JUnitExtension;
-
 import org.junit.Assert;
+
 import junit.framework.TestCase;
 
 public class CasIOUtilsTest extends TestCase{
@@ -218,11 +219,14 @@ public class CasIOUtilsTest extends Test
     }
     
     List<String> fsTypes = new ArrayList<>();
-    FSIterator<FeatureStructure> fsi = cas.getIndexRepository()
-            .getAllIndexedFS(cas.getTypeSystem().getTopType());
+//    FSIterator<FeatureStructure> fsi = cas.getIndexRepository()
+//            .getAllIndexedFS(cas.getTypeSystem().getTopType());
+    Collection<TOP> s = cas.getIndexedFSs();
+    Iterator<TOP> fsi = s.iterator();
     int fsCount = 0;
     while (fsi.hasNext()) {
-      String typeName = fsi.next().getType().getName();
+      TOP fs = (TOP) fsi.next();
+      String typeName = fs.getType().getName();
       if (!fsTypes.contains(typeName)) {
         fsTypes.add(typeName);
       }