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 2015/11/01 14:31:42 UTC

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

Author: schor
Date: Sun Nov  1 13:31:42 2015
New Revision: 1711762

URL: http://svn.apache.org/viewvc?rev=1711762&view=rev
Log:
[UIMA-4664][UIMA-4665]

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

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java?rev=1711762&r1=1711761&r2=1711762&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java Sun Nov  1 13:31:42 2015
@@ -19,18 +19,25 @@
 
 package org.apache.uima.cas.impl;
 
+import org.apache.uima.cas.FSIndex;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.admin.FSIndexComparator;
+import org.apache.uima.internal.util.IntPointerIterator;
+
 /**
  * Low-level FS index object. Use to obtain low-level iterators.
  * 
  */
-public interface LowLevelIndex {
+public interface LowLevelIndex<T extends FeatureStructure> extends FSIndex<T> {
 
   /**
    * Get a low-level, FS reference iterator.
    * 
    * @return An iterator for this index.
    */
-  LowLevelIterator ll_iterator();
+  default LowLevelIterator<T> ll_iterator() {
+    return ll_iterator(true);
+  };
 
   /**
    * Get a low-level, FS reference iterator. This iterator can be disambiguated. This means that
@@ -41,22 +48,59 @@ public interface LowLevelIndex {
    *          When set to <code>false</code>, iterator will be disambiguated.
    * @return An iterator for this index.
    */
-  LowLevelIterator ll_iterator(boolean ambiguous);
+  LowLevelIterator<T> ll_iterator(boolean ambiguous);
   
-  /**
-   * Get a low-level, FS reference iterator specifying instances of
-   * the precise type <b>only</b> (i.e. without listing the subtypes).
-   * 
-   * @return An iterator for the root type of this index.
-   */
-  LowLevelIterator ll_rootIterator();
-
-  /**
-   * Get the number of FSs in this index.
-   * 
-   * @return The size of this index.
-   */
-  int size();
+//  /**
+//   * Get a low-level, FS reference iterator specifying instances of
+//   * the precise type <b>only</b> (i.e. without listing the subtypes).
+//   * 
+//   * @return An iterator for the root type of this index.
+//   */
+//  LowLevelIterator<T> ll_rootIterator();
 
   int ll_compare(int ref1, int ref2);
+  
+  CASImpl getCasImpl();
+  
+  // incorporated from FSIndexImpl
+  
+  FSIndexComparator getComparatorForIndexSpecs();
+
+  default void flush() {   // probably not needed, but left for backwards compatibility  4/2015
+    throw new UnsupportedOperationException();
+  }
+
+  default IntPointerIterator getIntIterator() {   // probably not needed, but left for backwards compatibility 4/2015
+    return new IntPointerIterator() {
+
+      private LowLevelIterator<T> it = ll_iterator();
+   
+      @Override
+      public boolean isValid() { return it.isValid(); }
+      @Override
+      public int get() { return it.ll_get(); }
+      @Override
+      public void inc() { it.moveToNext(); }
+      @Override
+      public void dec() { it.moveToPrevious(); }
+      @Override
+      public void moveTo(int i) { it.moveTo(i); }
+      @Override
+      public void moveToFirst() { it.moveToFirst(); }
+      @Override
+      public void moveToLast() { it.moveToLast(); }
+      @Override
+      public Object copy() { 
+        IntPointerIterator newIt = getIntIterator();
+        if (isValid()) {
+          newIt.moveTo(it.ll_get());
+        } else { // is invalid
+          newIt.moveToFirst();
+          newIt.dec(); // make invalid
+        }
+        return newIt;
+      }
+    };
+  }
+
 }