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/05/14 22:32:51 UTC
svn commit: r1679456 - in
/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima:
cas/impl/CASImpl.java jcas/tcas/Annotation.java
jcas/tcas/Annotation_Type.java
Author: schor
Date: Thu May 14 20:32:50 2015
New Revision: 1679456
URL: http://svn.apache.org/r1679456
Log:
[UIMA-4396] tiny performance improvement in annotation getBegin/end
Modified:
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation.java
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation_Type.java
Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=1679456&r1=1679455&r2=1679456&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Thu May 14 20:32:50 2015
@@ -222,6 +222,10 @@ public class CASImpl extends AbstractCas
final private LongHeap longHeap = new LongHeap(); // for storing 64 bit values
+ // for efficiency in accessing the begin and end offsets of annotations
+ private int annotFeatOffset_begin;
+ private int annotFeatOffset_end;
+
// Base CAS for all views
final private CASImpl baseCAS;
@@ -983,6 +987,8 @@ public class CASImpl extends AbstractCas
// After the type system has been committed, we can create the
// index repository.
createIndexRepository();
+ svd.annotFeatOffset_begin = getFeatureOffset(ts.startFeatCode);
+ svd.annotFeatOffset_end = getFeatureOffset(ts.endFeatCode);
}
// internal use, public for cross class ref
@@ -3547,6 +3553,14 @@ public class CASImpl extends AbstractCas
return ll_getIntValue(fsRef, featureCode);
}
+ public int ll_getAnnotBegin(int fsRef) {
+ return ll_getIntValueFeatOffset(fsRef, svd.annotFeatOffset_begin);
+ }
+
+ public int ll_getAnnotEnd(int fsRef) {
+ return ll_getIntValueFeatOffset(fsRef, svd.annotFeatOffset_end);
+ }
+
/**
* This is the method all normal FS feature "setters" call before doing the set operation.
* <p style="margin-left:2em">
Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation.java?rev=1679456&r1=1679455&r2=1679456&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation.java Thu May 14 20:32:50 2015
@@ -61,17 +61,20 @@ public class Annotation extends Annotati
* getter for begin - gets beginning of span of annotation
*/
public int getBegin() {
- if (Annotation_Type.featOkTst && ((Annotation_Type) jcasType).casFeat_begin == null)
- this.jcasType.jcas.throwFeatMissing("begin", "uima.tcas.Annotation");
- return jcasType.ll_cas.ll_getIntValue(addr, ((Annotation_Type) jcasType).casFeatCode_begin);
+ // not needed - is built in
+// if (Annotation_Type.featOkTst && ((Annotation_Type) jcasType).casFeat_begin == null)
+// this.jcasType.jcas.throwFeatMissing("begin", "uima.tcas.Annotation");
+ return ((Annotation_Type)jcasType).getBegin(addr);
+// return jcasType.ll_cas.ll_getIntValue(addr, ((Annotation_Type) jcasType).casFeatCode_begin);
}
/*
* setter for begin - sets beginning of span of annotation
*/
public void setBegin(int v) {
- if (Annotation_Type.featOkTst && ((Annotation_Type) jcasType).casFeat_begin == null)
- this.jcasType.jcas.throwFeatMissing("begin", "uima.tcas.Annotation");
+ // not needed - is built in
+// if (Annotation_Type.featOkTst && ((Annotation_Type) jcasType).casFeat_begin == null)
+// this.jcasType.jcas.throwFeatMissing("begin", "uima.tcas.Annotation");
jcasType.ll_cas.ll_setIntValue(addr, ((Annotation_Type) jcasType).casFeatCode_begin, v);
}
@@ -83,17 +86,20 @@ public class Annotation extends Annotati
* getter for end - gets ending of span of annotation
*/
public int getEnd() {
- if (Annotation_Type.featOkTst && ((Annotation_Type) jcasType).casFeat_end == null)
- this.jcasType.jcas.throwFeatMissing("end", "uima.tcas.Annotation");
- return jcasType.ll_cas.ll_getIntValue(addr, ((Annotation_Type) jcasType).casFeatCode_end);
+ // not needed - is built in
+// if (Annotation_Type.featOkTst && ((Annotation_Type) jcasType).casFeat_end == null)
+// this.jcasType.jcas.throwFeatMissing("end", "uima.tcas.Annotation");
+ return ((Annotation_Type)jcasType).getEnd(addr);
+// return jcasType.ll_cas.ll_getIntValue(addr, ((Annotation_Type) jcasType).casFeatCode_end);
}
/*
* setter for end - sets ending of span of annotation
*/
public void setEnd(int v) {
- if (Annotation_Type.featOkTst && ((Annotation_Type) jcasType).casFeat_end == null)
- this.jcasType.jcas.throwFeatMissing("end", "uima.tcas.Annotation");
+ // not needed - is built in
+// if (Annotation_Type.featOkTst && ((Annotation_Type) jcasType).casFeat_end == null)
+// this.jcasType.jcas.throwFeatMissing("end", "uima.tcas.Annotation");
jcasType.ll_cas.ll_setIntValue(addr, ((Annotation_Type) jcasType).casFeatCode_end, v);
}
Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation_Type.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation_Type.java?rev=1679456&r1=1679455&r2=1679456&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation_Type.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation_Type.java Thu May 14 20:32:50 2015
@@ -58,9 +58,11 @@ public class Annotation_Type extends org
final int casFeatCode_begin;
public int getBegin(int addr) {
- if (featOkTst && casFeat_begin == null)
- this.jcas.throwFeatMissing("begin", "uima.tcas.Annotation");
- return ll_cas.ll_getIntValue(addr, casFeatCode_begin);
+ // not needed - is built in
+// if (featOkTst && casFeat_begin == null)
+// this.jcas.throwFeatMissing("begin", "uima.tcas.Annotation");
+ return casImpl.ll_getAnnotBegin(addr);
+// return ll_cas.ll_getIntValue(addr, casFeatCode_begin);
}
public void setBegin(int addr, int v) {
@@ -72,11 +74,13 @@ public class Annotation_Type extends org
final Feature casFeat_end;
final int casFeatCode_end;
-
+
public int getEnd(int addr) {
- if (featOkTst && casFeat_end == null)
- this.jcas.throwFeatMissing("end", "uima.tcas.Annotation");
- return ll_cas.ll_getIntValue(addr, casFeatCode_end);
+ // not needed - is built in
+// if (featOkTst && casFeat_end == null)
+// this.jcas.throwFeatMissing("end", "uima.tcas.Annotation");
+ return casImpl.ll_getAnnotEnd(addr);
+// return ll_cas.ll_getIntValue(addr, casFeatCode_end);
}
public void setEnd(int addr, int v) {