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 2013/03/05 15:53:47 UTC

svn commit: r1452822 - in /uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima: cas/impl/ internal/util/

Author: schor
Date: Tue Mar  5 14:53:47 2013
New Revision: 1452822

URL: http://svn.apache.org/r1452822
Log:
[UIMA-2715] [UIMA-2716] Committing to branch for now.

Modified:
    uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
    uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexComparatorImpl.java
    uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
    uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/IntVector.java
    uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/SortedIntSet.java

Modified: uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=1452822&r1=1452821&r2=1452822&view=diff
==============================================================================
--- uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original)
+++ uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Tue Mar  5 14:53:47 2013
@@ -1559,9 +1559,10 @@ public class CASImpl extends AbstractCas
     // Get indexes for base CAS
     fsLoopIndex = this.svd.baseCAS.indexRepository.getIndexedFSs();
     v.add(fsLoopIndex.length);
-    for (int k = 0; k < fsLoopIndex.length; k++) {
-      v.add(fsLoopIndex[k]);
-    }
+    v.add(fsLoopIndex, 0, fsLoopIndex.length);
+//    for (int k = 0; k < fsLoopIndex.length; k++) {
+//      v.add(fsLoopIndex[k]);
+//    }
 
     // Get indexes for each SofaFS in the CAS
     for (int sofaNum = 1; sofaNum <= numViews; sofaNum++) {
@@ -1613,9 +1614,10 @@ public class CASImpl extends AbstractCas
     }
     
     v.add(newSofas.size());
-    for (int k = 0; k < newSofas.size(); k++) {
-      v.add(newSofas.get(k));
-    }
+    v.add(newSofas.getArray(), 0, newSofas.size());
+//    for (int k = 0; k < newSofas.size(); k++) {
+//      v.add(newSofas.get(k));
+//    }
 
     // Get indexes for each SofaFS in the CAS
     for (int sofaNum = 1; sofaNum <= numViews; sofaNum++) {
@@ -1631,17 +1633,20 @@ public class CASImpl extends AbstractCas
         fsReindexed = INT0;
       }
       v.add(fsLoopIndex.length);
-      for (int k = 0; k < fsLoopIndex.length; k++) {
-        v.add(fsLoopIndex[k]);
-      }
+      v.add(fsLoopIndex, 0, fsLoopIndex.length);
+//      for (int k = 0; k < fsLoopIndex.length; k++) {
+//        v.add(fsLoopIndex[k]);
+//      }
       v.add(fsDeletedFromIndex.length);
-      for (int k = 0; k < fsDeletedFromIndex.length; k++) {
-        v.add(fsDeletedFromIndex[k]);
-      }
+      v.add(fsDeletedFromIndex, 0, fsDeletedFromIndex.length);
+//      for (int k = 0; k < fsDeletedFromIndex.length; k++) {
+//        v.add(fsDeletedFromIndex[k]);
+//      }
       v.add(fsReindexed.length);
-      for (int k = 0; k < fsReindexed.length; k++) {
-        v.add(fsReindexed[k]);
-      }
+      v.add(fsReindexed, 0, fsReindexed.length);
+//      for (int k = 0; k < fsReindexed.length; k++) {
+//        v.add(fsReindexed[k]);
+//      }
     }
     return v.toArray();
   }
@@ -3796,6 +3801,10 @@ public class CASImpl extends AbstractCas
     final int offset = this.getHeap().heap[getArrayStartAddress(fsRef)];
     long value = Double.doubleToLongBits(d);
     this.getLongHeap().setHeapValue(value, offset + position);
+    if (this.svd.trackingMark != null) {
+      this.logFSUpdate(fsRef, offset+position, ModifiedHeap.LONGHEAP, 1);
+    }
+
   }
 
   public void ll_setDoubleArrayValue(int fsRef, int position, double value, boolean doTypeChecks) {

Modified: uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexComparatorImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexComparatorImpl.java?rev=1452822&r1=1452821&r2=1452822&view=diff
==============================================================================
--- uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexComparatorImpl.java (original)
+++ uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexComparatorImpl.java Tue Mar  5 14:53:47 2013
@@ -169,10 +169,12 @@ public class FSIndexComparatorImpl imple
     FSIndexComparatorImpl copy = new FSIndexComparatorImpl(this.cas);
     copy.type = this.type;
     final int max = this.getNumberOfKeys();
+    copy.compVector.add(this.compVector.getArray(), 0, this.compVector.size());
+    copy.keyTypeVector.add(this.keyTypeVector.getArray(), 0, this.keyTypeVector.size());
     for (int i = 0; i < max; i++) {
       copy.keyVector.add(this.keyVector.get(i));
-      copy.compVector.add(this.compVector.get(i));
-      copy.keyTypeVector.add(this.keyTypeVector.get(i));
+//      copy.compVector.add(this.compVector.get(i));
+//      copy.keyTypeVector.add(this.keyTypeVector.get(i));
     }
     return copy;
   }

Modified: uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java?rev=1452822&r1=1452821&r2=1452822&view=diff
==============================================================================
--- uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java (original)
+++ uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java Tue Mar  5 14:53:47 2013
@@ -68,13 +68,13 @@ public class FSIndexRepositoryImpl imple
   private class IndexIteratorCachePair implements Comparable<IndexIteratorCachePair> {
 
     // The "root" index, i.e., index of the type of the iterator.
-    private FSLeafIndexImpl index = null;
+    private FSLeafIndexImpl<?> index = null;
 
     // A list of indexes (the sub-indexes that we need for an
     // iterator). I.e., one index for each type that's subsumed by the
     // iterator
     // type.
-    private ArrayList<FSLeafIndexImpl> iteratorCache = null;
+    private ArrayList<FSLeafIndexImpl<?>> iteratorCache = null;
 
     private IndexIteratorCachePair() {
       super();
@@ -102,7 +102,7 @@ public class FSIndexRepositoryImpl imple
       if (this.iteratorCache != null) {
         return;
       }
-      this.iteratorCache = new ArrayList<FSLeafIndexImpl>();
+      this.iteratorCache = new ArrayList<FSLeafIndexImpl<?>>();
       final Type rootType = this.index.getComparator().getType();
       ArrayList<Type> allTypes = null;
       if (this.index.getIndexingStrategy() == FSIndex.DEFAULT_BAG_INDEX) {
@@ -211,12 +211,12 @@ public class FSIndexRepositoryImpl imple
     private void initPointerIterator(IndexIteratorCachePair iicp0) {
       this.iicp = iicp0;
       // Make sure the iterator cache exists.
-      final ArrayList<FSLeafIndexImpl> iteratorCache = iicp0.iteratorCache;
+      final ArrayList<FSLeafIndexImpl<?>> iteratorCache = iicp0.iteratorCache;
       this.indexes = new ComparableIntPointerIterator[iteratorCache.size()];
       this.iteratorComparator = iteratorCache.get(0);
       ComparableIntPointerIterator it;
       for (int i = 0; i < this.indexes.length; i++) {
-        final FSLeafIndexImpl leafIndex = iteratorCache.get(i);
+        final FSLeafIndexImpl<?> leafIndex = iteratorCache.get(i);
         it = leafIndex.pointerIterator(this.iteratorComparator,
             FSIndexRepositoryImpl.this.detectIllegalIndexUpdates,
             ((TypeImpl) leafIndex.getType()).getCode());
@@ -645,8 +645,8 @@ public class FSIndexRepositoryImpl imple
     private void initPointerIterator(IndexIteratorCachePair iicp0) {
       this.iicp = iicp0;
       // Make sure the iterator cache exists.
-      final ArrayList<FSLeafIndexImpl> iteratorCache = iicp0.iteratorCache;
-      final FSLeafIndexImpl leafIndex = iteratorCache.get(0);
+      final ArrayList<FSLeafIndexImpl<?>> iteratorCache = iicp0.iteratorCache;
+      final FSLeafIndexImpl<?> leafIndex = iteratorCache.get(0);
       this.index = leafIndex.pointerIterator(leafIndex,
           FSIndexRepositoryImpl.this.detectIllegalIndexUpdates,
           ((TypeImpl) leafIndex.getType()).getCode());
@@ -833,7 +833,7 @@ public class FSIndexRepositoryImpl imple
       this.iicp.createIndexIteratorCache();
       // int size = this.iicp.index.size();
       int size = 0;
-      final ArrayList<FSLeafIndexImpl> subIndex = this.iicp.iteratorCache;
+      final ArrayList<FSLeafIndexImpl<?>> subIndex = this.iicp.iteratorCache;
       final int max = subIndex.size();
       for (int i = 0; i < max; i++) {
         size += subIndex.get(i).size();
@@ -1073,7 +1073,7 @@ public class FSIndexRepositoryImpl imple
     }
     final ArrayList<IndexIteratorCachePair> indexVector = this.indexArray[typeCode];
     // final int vecLen = indexVector.size();
-    FSLeafIndexImpl ind;
+    FSLeafIndexImpl<?> ind;
     switch (indexType) {
     case FSIndex.SET_INDEX: {
       ind = new FSRBTSetIndex(this.cas, type, indexType);
@@ -1458,8 +1458,8 @@ public class FSIndexRepositoryImpl imple
       // index, pick one arbitrarily and add its FSs (since it contains all
       // FSs that all other indexes for the same type contain). If there are
       // only set indexes, create a set of the FSs in those indexes, since they
-      // may all contain different elements (FSs that are duplicates for one
-      // index may not be duplicates for a different one).
+      // may all contain different elements (different FSs that have the same "key"
+      //   are duplicates for one index, but may not be duplicates for a different one).
       cv = new ArrayList<IndexIteratorCachePair>();
       for (int j = 0; j < jMax; j++) {
         iicp = iv.get(j);
@@ -1467,14 +1467,17 @@ public class FSIndexRepositoryImpl imple
         if (indStrat == FSIndex.SET_INDEX) {
           cv.add(iicp);
         } else {
-          if (cv.size() > 0) {
-            cv = new ArrayList<IndexIteratorCachePair>();
-          }
+          cv.clear();  // only need to save this one
           cv.add(iicp);
           break;
         }
       }
       if (cv.size() > 0) {
+        // Note: This next loop removes duplicates (and also sorts
+        // the fs addrs associated with one type)
+        // Duplicates arise from having mulitple sets combined, and
+        // also if a non-set index had the same identical FS added
+        // multiple times.
         set = new SortedIntSet();
         for (int k = 0; k < cv.size(); k++) {
           it = cv.get(k).index.refIterator();
@@ -1483,9 +1486,10 @@ public class FSIndexRepositoryImpl imple
             it.inc();
           }
         }
-        for (int k = 0; k < set.size(); k++) {
-          v.add(set.get(k));
-        }
+        v.add(set.getArray(), 0, set.size());  // bulk add of all elements
+//        for (int k = 0; k < set.size(); k++) {
+//          v.add(set.get(k));
+//        }
       }
     }
     return v.toArray();

Modified: uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/IntVector.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/IntVector.java?rev=1452822&r1=1452821&r2=1452822&view=diff
==============================================================================
--- uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/IntVector.java (original)
+++ uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/IntVector.java Tue Mar  5 14:53:47 2013
@@ -38,9 +38,9 @@ public class IntVector implements Serial
 
   private static final int default_multiplication_limit = 2000000;
 
-  private int growth_factor;
+  final private int growth_factor;
 
-  private int multiplication_limit;
+  final private int multiplication_limit;
 
   // Points to the next free cell in the array.
   protected int pos = 0;
@@ -115,6 +115,22 @@ public class IntVector implements Serial
   }
 
   /**
+   * Add an array of elements to the end.
+   * @param elements
+   */
+  public void add(int[] elements) {
+    add(elements, 0, elements.length);
+  }
+  
+  public void add(int[] elements, int startpos, int endpos) {
+    final int len = endpos - startpos;
+    final int posNow = this.pos;
+    ensure_size(this.pos + len);  // changes pos
+    System.arraycopy(elements, startpos, this.array, posNow, len);
+//    this.pos += len;  done by ensure_size    
+  }
+  
+  /**
    * Add an element at the end of vector. Behaves like add(Object o) of
    * {@link java.util.Vector Vector}.
    */

Modified: uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/SortedIntSet.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/SortedIntSet.java?rev=1452822&r1=1452821&r2=1452822&view=diff
==============================================================================
--- uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/SortedIntSet.java (original)
+++ uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/internal/util/SortedIntSet.java Tue Mar  5 14:53:47 2013
@@ -127,6 +127,10 @@ public class SortedIntSet {
   public int[] toArray() {
     return this.vector.toArrayCopy();
   }
+  
+  public int[] getArray() {
+    return vector.getArray();
+  }
 
   // public static void main(String [] args) {