Author: rec
Date: Tue Aug  9 20:23:45 2016
New Revision: 1755645

URL: http://svn.apache.org/viewvc?rev=1755645&view=rev
Log:
[UIMA-5046] Faster indexCovered implementation
- Add not about ordering in JavaDoc and unit test

Modified:
    
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
    
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
    
uima/uimafit/trunk/uimafit-core/src/test/java/org/apache/uima/fit/util/JCasUtilTest.java

Modified: 
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
URL: 
http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java?rev=1755645&r1=1755644&r2=1755645&view=diff
==============================================================================
--- 
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
 (original)
+++ 
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
 Tue Aug  9 20:23:45 2016
@@ -754,6 +754,8 @@ public final class CasUtil {
    * Create an index for quickly lookup up the annotations covered by a 
particular annotation. This
    * is preferable to using {@link #selectCovered(CAS, Type, int, int)} 
because the overhead of
    * scanning the CAS occurs only when the index is build. Subsequent lookups 
to the index are fast.
+   * The order of entries in the map is not defined. However, lists of covered 
annotations in
+   * the map are guaranteed to be in the same order as in the UIMA default 
annotation index.
    * 
    * @param cas
    *          a CAS.

Modified: 
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
URL: 
http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java?rev=1755645&r1=1755644&r2=1755645&view=diff
==============================================================================
--- 
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
 (original)
+++ 
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
 Tue Aug  9 20:23:45 2016
@@ -471,6 +471,8 @@ public final class JCasUtil {
    * Create an index for quickly lookup up the annotations covered by a 
particular annotation. This
    * is preferable to using {@link #selectCovered(JCas, Class, int, int)} 
because the overhead of
    * scanning the CAS occurs only when the index is build. Subsequent lookups 
to the index are fast.
+   * The order of entries in the map is not defined. However, lists of covered 
annotations in
+   * the map are guaranteed to be in the same order as in the UIMA default 
annotation index.
    * 
    * @param <T>
    *          the covering JCas type.

Modified: 
uima/uimafit/trunk/uimafit-core/src/test/java/org/apache/uima/fit/util/JCasUtilTest.java
URL: 
http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-core/src/test/java/org/apache/uima/fit/util/JCasUtilTest.java?rev=1755645&r1=1755644&r2=1755645&view=diff
==============================================================================
--- 
uima/uimafit/trunk/uimafit-core/src/test/java/org/apache/uima/fit/util/JCasUtilTest.java
 (original)
+++ 
uima/uimafit/trunk/uimafit-core/src/test/java/org/apache/uima/fit/util/JCasUtilTest.java
 Tue Aug  9 20:23:45 2016
@@ -132,6 +132,8 @@ public class JCasUtilTest extends Compon
       initRandomCas(cas, 10 * i);
 
       JCas jcas = cas.getJCas();
+      Collection<Sentence> sentences = select(jcas, Sentence.class);
+      
       long timeNaive = 0;
       long timeOptimized = 0;
       
@@ -140,7 +142,13 @@ public class JCasUtilTest extends Compon
       Map<Sentence, Collection<Token>> index = indexCovered(jcas, 
Sentence.class, Token.class);
       timeIndexed = System.currentTimeMillis() - timeIndexed;
       
-      for (Sentence t : select(jcas, Sentence.class)) {
+      // -- The order of entries in the index is NOT defined!
+      // Check that order of indexed sentences corresponds to regular 
CAS-index order
+      // List<Sentence> relevantSentences = new ArrayList<>(sentences);
+      // relevantSentences.retainAll(index.keySet());
+      // assertEquals(relevantSentences, new ArrayList<>(index.keySet()));
+      
+      for (Sentence t : sentences) {
         long ti = System.currentTimeMillis();
         // The naive approach is assumed to be correct
         List<Token> expected = selectCovered(jcas, Token.class, t.getBegin(), 
t.getEnd());


Reply via email to