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/02/09 23:12:24 UTC
svn commit: r1729482 - in
/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl:
TypeImpl.java TypeImpl_array.java
Author: schor
Date: Tue Feb 9 22:12:23 2016
New Revision: 1729482
URL: http://svn.apache.org/viewvc?rev=1729482&view=rev
Log:
[UIMA-4674] add missing @Override and isAuxStoredArray. Add hasRefFeature. Return more specific TypeImpl for getSuperType(). Add method to get the space on the V2 heap.
Modified:
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java?rev=1729482&r1=1729481&r2=1729482&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java Tue Feb 9 22:12:23 2016
@@ -104,6 +104,11 @@ public class TypeImpl implements Type, C
*/
public final boolean isRefType; // not a primitive, can be a FeatureStructure in the CAS, added to indexes etc.
+ /**
+ * true for FSarrays non-arrays having 1 or more refs to FSs
+ */
+ boolean hasRefFeature; // true for FSarrays non-arrays having 1 or more refs to FSs
+
/* ***************** type hierarchy *****************/
private final TypeImpl superType;
@@ -124,7 +129,7 @@ public class TypeImpl implements Type, C
int nbrOfUsedRefDataSlots = -1;
// for journalling allocation: This is a 0-based offset for all features in feature order
- int highestOffset = -1;
+ int highestOffset = -1;
private TypeImpl() {
this.name = null;
@@ -223,6 +228,8 @@ public class TypeImpl implements Type, C
}
slotKind = TypeSystemImpl.getSlotKindFromType(this);
+
+ hasRefFeature = name.equals(CAS.TYPE_NAME_FS_ARRAY); // initialization of other cases done at commit time
}
/**
@@ -240,7 +247,7 @@ public class TypeImpl implements Type, C
*
* @return The super type or null for Top.
*/
- public Type getSuperType() {
+ public TypeImpl getSuperType() {
return this.superType;
}
@@ -334,13 +341,16 @@ public class TypeImpl implements Type, C
/**
* Check if this is an annotation type.
*
- * @return <code>true</code>, if <code>this</code> is an annotation type; <code>false</code>,
+ * @return <code>true</code>, if <code>this</code> is an annotation type or subtype; <code>false</code>,
* else.
*/
public boolean isAnnotationType() {
return false;
}
+ /**
+ * @return true for AnnotationBaseType or any subtype
+ */
public boolean isAnnotationBaseType() {
return false;
}
@@ -468,6 +478,16 @@ public class TypeImpl implements Type, C
staticMergedFeaturesList.clear();
staticMergedFeaturesList.addAll(superType.getFeatureImpls());
staticMergedFeaturesList.addAll(staticMergedFeaturesIntroducedByThisType);
+ if (superType.hasRefFeature) {
+ hasRefFeature = true;
+ } else {
+ for (FeatureImpl fi : staticMergedFeaturesIntroducedByThisType) {
+ if (fi.getRangeImpl().isRefType) {
+ hasRefFeature = true;
+ break;
+ }
+ }
+ }
}
}
@@ -606,11 +626,23 @@ public class TypeImpl implements Type, C
return false; // overridden by array subtype
}
+ /**
+ * model how v2 stores this - needed for backward compatibility / (de)serialization
+ * @return true if it is an array and is stored in the main heap (int, float, or string)
+ */
boolean isHeapStoredArray() {
return false; // overridden by array subtype, used for backward compatibility
}
/**
+ * model how v2 stores this - needed for backward compatibility / (de)serialization
+ * @return true if it is an array and is one of the 3 aux arrays (byte (also used for boolean) short, long
+ */
+ boolean isAuxStoredArray() {
+ return false; // overridden by array subtype, used for backward compatibility
+ }
+
+ /**
* @see org.apache.uima.cas.Type#isStringSubtype()
*/
@Override
@@ -769,6 +801,23 @@ public class TypeImpl implements Type, C
}
/**
+ * Get the v2 heap size for types with features
+ * @return the main heap size for this FeatureStructure, assuming it's not a heap stored array (see below)
+ */
+ public int getFsSpaceReq() {
+ return getFeatureImpls().size() + 1; // number of feats + 1 for the type code
+ }
+
+ /**
+ * get the v2 heap size for types
+ * @param length for heap-stored arrays, the array length
+ * @return the main heap size for this FeatureStructure
+ */
+ public int getFsSpaceReq(int length) {
+ return isHeapStoredArray() ? (2 + length) : isArray() ? 3 : getFsSpaceReq();
+ }
+
+ /**
* A special instance used in CasCopier to identify a missing type
*/
public final static TypeImpl singleton = new TypeImpl();
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java?rev=1729482&r1=1729481&r2=1729482&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java Tue Feb 9 22:12:23 2016
@@ -41,10 +41,12 @@ public class TypeImpl_array extends Type
this.slotKind = slotKind;
}
+ @Override
public Type getComponentType() {
return componentType;
}
+ @Override
TypeImpl consolidateType(TypeImpl topType, TypeImpl fsArrayType) {
if (!(componentType instanceof TypeImpl_primitive)) {
return fsArrayType; // booleanArrayType, stringArrayType etc.
@@ -58,10 +60,16 @@ public class TypeImpl_array extends Type
return true;
}
+ @Override
boolean isHeapStoredArray() {
return isHeapStoredArray;
}
+ @Override
+ boolean isAuxStoredArray() {
+ return !isHeapStoredArray;
+ }
+
/** Component Slot Kind */
@Override
public SlotKind getComponentSlotKind() {