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 2016/03/29 23:31:17 UTC
svn commit: r1737057 -
/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java
Author: schor
Date: Tue Mar 29 21:31:17 2016
New Revision: 1737057
URL: http://svn.apache.org/viewvc?rev=1737057&view=rev
Log:
[UIMA-4674] fast path if type systems are equal.
Modified:
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java?rev=1737057&r1=1737056&r2=1737057&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java Tue Mar 29 21:31:17 2016
@@ -205,6 +205,8 @@ public class CasCopier {
private final Int2ObjListMap<TypeImpl> src2TgtType;
private final Int2ObjListMap<FeatureImpl> src2TgtFeat;
+ private final boolean isEqualTypeSystems;
+
//
// private final TypeImpl srcStringType;
@@ -313,6 +315,8 @@ public class CasCopier {
} else {
isChangeViewName = !srcViewName.equals(tgtViewName);
}
+
+ isEqualTypeSystems = srcTsi.equals(tgtTsi);
}
@@ -786,12 +790,54 @@ public class CasCopier {
private <T extends FeatureStructure> void copyFeatures(T srcFSi, T tgtFSi) {
TOP srcFS = (TOP) srcFSi;
TOP tgtFS = (TOP) tgtFSi;
+
+ // guaranteed not an array at this point
+
+ if (isEqualTypeSystems) {
+
+ for (FeatureImpl fi : srcFS.getTypeImpl().getFeatureImpls()) {
+ final int adjOffset = fi.getAdjustedOffset();
+ if (fi.isInInt) {
+ tgtFS._setIntValueNcNj(adjOffset, srcFS._getIntValueNc(adjOffset));
+ } else if (!fi.getRangeImpl().isRefType) {
+ tgtFS._setRefValueCommon(adjOffset, srcFS._getRefValueCommon(adjOffset));
+ } else { // is FS reference
+ // feature is a reference to another FS, so enqueue that to copy
+ // unless it's the sofa feature for AnnotationBase - that's feature final, set when created
+ if (fi.isAnnotBaseSofaRef) {
+ continue;
+ }
+ TOP refFs = srcFS._getFeatureValueNc(adjOffset);
+ if (null != refFs) {
+ tgtFS._setFeatureValueNcNj(adjOffset, copyFsInner(refFs)); // recursive call
+ }
+ }
+ }
+ return;
+// final TypeImpl tgtType = tgtFS._typeImpl;
+// Sofa sofa = (tgtType.isAnnotationBaseType()) ? ((AnnotationBase)tgtFS).getSofa() : null;
+// tgtFS._copyIntAndRefArraysEqTypesFrom(srcFS);
+// if (tgtType.isAnnotationBaseType()) {
+// tgtFS._setFeatureValueNcNj(TypeSystemConstants.annotBaseSofaFeatAdjOffset, sofa);
+// }
+//
+// if (tgtType.hasRefFeature()) {
+// for (FeatureImpl fi : tgtFS._typeImpl.getFeatureImpls()) {
+// if (!fi.getRangeImpl().isRefType) continue;
+// final int adjOffset = fi.getAdjustedOffset();
+// TOP refFs = tgtFS._getFeatureValueNc(adjOffset);
+// if (null != refFs) {
+// tgtFS._setFeatureValueNcNj(adjOffset, copyFsInner(refFs)); // recursive call
+// }
+// }
+// }
+ }
+
for (FeatureImpl fi : srcFS.getTypeImpl().getFeatureImpls()) {
FeatureImpl tgtFi = getTargetFeature(fi);
if (null == tgtFi) {
continue; // skip copying features not in the target type system
}
-
if (!CASImpl.copyFeatureExceptFsRef(srcFS, fi, tgtFS, tgtFi)) {
// feature is a reference to another FS, so enqueue that to copy
// unless it's the sofa feature for AnnotationBase - that's feature final, set when created