You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2020/11/04 07:32:25 UTC

[uima-uimafit] branch bugfix/UIMA-6292-selectCovering-is-slow-v3 updated: [UIMA-6292] selectCovering is slow

This is an automated email from the ASF dual-hosted git repository.

rec pushed a commit to branch bugfix/UIMA-6292-selectCovering-is-slow-v3
in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git


The following commit(s) were added to refs/heads/bugfix/UIMA-6292-selectCovering-is-slow-v3 by this push:
     new c5599fc  [UIMA-6292] selectCovering is slow
c5599fc is described below

commit c5599fcd6c63b283a75c27f8e4083610a466c3a7
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Wed Nov 4 08:19:44 2020 +0100

    [UIMA-6292] selectCovering is slow
    
    - Avoid repeatedly calling ts.subsumes by obtaining a properly-typed index in the first place.
---
 uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
index b3a77c6..50b0dfc 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
@@ -42,7 +42,6 @@ import org.apache.uima.cas.CASRuntimeException;
 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.cas.impl.Subiterator;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.cas.text.AnnotationIndex;
@@ -715,16 +714,15 @@ public final class CasUtil {
    */
   public static List<AnnotationFS> selectCovering(CAS cas, Type type, int begin, int end) {
 
-    TypeSystem ts = cas.getTypeSystem();
     List<AnnotationFS> list = new ArrayList<AnnotationFS>();
     
     // withSnapshotIterators() not needed here since we copy the FSes to a list anyway    
-    FSIterator<AnnotationFS> iter = cas.getAnnotationIndex().iterator();
+    FSIterator<AnnotationFS> iter = type == null ? cas.getAnnotationIndex().iterator()
+            : cas.getAnnotationIndex(type).iterator();
     
     while (iter.hasNext()) {
       AnnotationFS a = iter.next();
-      if ((a.getBegin() <= begin) && (a.getEnd() >= end)
-              && ((type == null) || (ts.subsumes(type, a.getType())))) {
+      if ((a.getBegin() <= begin) && (a.getEnd() >= end)) {
         list.add(a);
       }
     }