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 2016/03/29 23:41:28 UTC

svn commit: r1737064 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java

Author: schor
Date: Tue Mar 29 21:41:27 2016
New Revision: 1737064

URL: http://svn.apache.org/viewvc?rev=1737064&view=rev
Log:
[UIMA-4664] set the "hasSetIndex" value appropriately.  Rework removeFS_ret to incorporate one of its callers optimizations. Remove that caller, replace with removeFS_ret. Don't increment the illegalindexupdatedetector if nothing is removed from the index. 

Modified:
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java?rev=1737064&r1=1737063&r2=1737064&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java Tue Mar 29 21:41:27 2016
@@ -234,6 +234,10 @@ public class FSIndexRepositoryImpl imple
       case FSIndex.SORTED_INDEX:
         aSortedIndex = i;
         break;
+      case FSIndex.SET_INDEX:
+        hasSetIndex = true;
+        break;
+      default: Misc.internalError();
       }
       indexesForType.add(iicp);
     }
@@ -1279,12 +1283,31 @@ public class FSIndexRepositoryImpl imple
       return false;
     }
     final int typeCode = fs._typeImpl.getCode();
-    incrementIllegalIndexUpdateDetector(typeCode);
-    final ArrayList<FsIndex_iicp<TOP>> idxList = getIndexesForType(typeCode).indexesForType;
+    final IndexesForType i4t = getIndexesForType(typeCode);
+    final ArrayList<FsIndex_iicp<TOP>> indexes4type = i4t.indexesForType;
 
     boolean wasRemoved = false;
+     
+    /** 
+     * some optimization speedup 
+     * - skip remove if 
+     *   
+     *   -- there is no sorted index AND
+     *   -- there is a bag index
+     *   -- but it doesn't contain the item
+     */
+
+    if (i4t.aSortedIndex < 0) {
+      int bi = i4t.aBagIndex;  // >= 0 if there is a bag index
+      if (bi < 0 && !i4t.hasSetIndex) {
+        return false;  // no indexes defined for this type
+      }
+      if (bi >= 0 && !i4t.indexesForType.get(bi).fsIndex_singletype.contains(fs)) {
+        return false;  // not in defined bag index
+      }
+    }
     
-    for (FsIndex_iicp<TOP> iicp : idxList) {
+    for (FsIndex_iicp<TOP> iicp : indexes4type) {
       FsIndex_singletype<TOP> st = iicp.fsIndex_singletype;
       if (skipBagIndexes && !st.isSetOrSorted()) {
         continue;
@@ -1299,6 +1322,7 @@ public class FSIndexRepositoryImpl imple
 //           .mapToInt(st -> st.deleteFS(fs) ? 1 : 0).sum();
     
     if (wasRemoved) {
+      incrementIllegalIndexUpdateDetector(typeCode);
       if (this.cas.getCurrentMark() != null) {
         logIndexOperation(fs, ITEM_REMOVED_FROM_INDEX);
       }
@@ -1462,28 +1486,29 @@ public class FSIndexRepositoryImpl imple
    * @return true if this fs was in the indexes and will need to be added back.
    */
   boolean removeIfInCorrputableIndexInThisView(FeatureStructure afs) {
-    TOP fs = (TOP) afs;
-    TypeImpl ti = fs._typeImpl;
-    final IndexesForType i4t = getIndexesForType(ti.getCode());
- 
-    int si = i4t.aSortedIndex;  
-    if (si >= 0) { // then we have a sorted index
-      return removeFS_ret(fs, SKIP_BAG_INDEXES);
-    }
-    
-    int bi = i4t.aBagIndex;
-    if (bi >= 0) { // have one or more bag indexes including default bag index, for this type
-      // use the bag index to stop if it doesn't contain the FS, because bag contains testing is fast..
-      if (!i4t.indexesForType.get(bi).fsIndex_singletype.contains(fs)) {
-        return false;
-      }
-      if (i4t.hasSetIndex) {
-        return removeFS_ret(fs, SKIP_BAG_INDEXES);
-      }
-    }
-    
-    // have no bag index, no sort index (implies index is empty) 
-    return false;
+    return removeFS_ret((TOP) afs, SKIP_BAG_INDEXES);
+//    TOP fs = (TOP) afs;
+//    TypeImpl ti = fs._typeImpl;
+//    final IndexesForType i4t = getIndexesForType(ti.getCode());
+// 
+//    int si = i4t.aSortedIndex;  
+//    if (si >= 0) { // then we have a sorted index
+//      return removeFS_ret(fs, SKIP_BAG_INDEXES);
+//    }
+//    
+//    int bi = i4t.aBagIndex;
+//    if (bi >= 0) { // have one or more bag indexes including default bag index, for this type
+//      // use the bag index to stop if it doesn't contain the FS, because bag contains testing is fast..
+//      if (!i4t.indexesForType.get(bi).fsIndex_singletype.contains(fs)) {
+//        return false;
+//      }
+//      if (i4t.hasSetIndex) {
+//        return removeFS_ret(fs, SKIP_BAG_INDEXES);
+//      }
+//    }
+//    
+//    // have no bag index, no sort index (implies index is empty) 
+//    return false;
   }
   
 //  /**