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/09/07 21:30:35 UTC

svn commit: r1759709 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java

Author: schor
Date: Wed Sep  7 21:30:34 2016
New Revision: 1759709

URL: http://svn.apache.org/viewvc?rev=1759709&view=rev
Log:
[UIMA-4674] add precomputed feature of type - the number of long slots - needed for modelling for binary serialization

Modified:
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.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=1759709&r1=1759708&r2=1759709&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 Wed Sep  7 21:30:34 2016
@@ -82,6 +82,8 @@ public class TypeImpl implements Type, C
   
   protected final boolean isLongOrDouble;  // for code generation
   
+  int nbrOfLongOrDoubleFeatures = 0; 
+  
   /**
    * False for non creatable (as Feature Structures) values (e.g. byte, integer, string) and
    * also false for array built-ins (which can be Feature Structures, can be added-to-indexes, etc.)
@@ -508,19 +510,22 @@ public class TypeImpl implements Type, C
     }    
   }
   
-  private void computeHasRef() {
+  private void computeHasXxx() {
+    nbrOfLongOrDoubleFeatures = superType.getNbrOfLongOrDoubleFeatures();
     if (superType.hasRefFeature) {
       hasRefFeature = true;
-    } else {
-      for (FeatureImpl fi : staticMergedFeaturesIntroducedByThisType) {
-        if (fi.getRangeImpl().isRefType) {
-          hasRefFeature = true;
-          break;
-        }
+    }
+    
+    for (FeatureImpl fi : staticMergedFeaturesIntroducedByThisType) {
+      if (!hasRefFeature && fi.getRangeImpl().isRefType) {
+        hasRefFeature = true;
+      }
+      if (fi.getRangeImpl().isLongOrDouble) {
+        nbrOfLongOrDoubleFeatures ++;
       }
     }
   }
-  
+    
   public Stream<FeatureImpl> getFeaturesAsStream() {
     return Arrays.stream(getFeatureImpls());
   }
@@ -838,7 +843,7 @@ public class TypeImpl implements Type, C
     if (level != 1) {
       // skip for top level; no features there, but no super type either
       getFeatureImpls(); // also done for side effect of computingcomputeStaticMergedFeaturesList();
-      computeHasRef();
+      computeHasXxx();
     }
      
     depthFirstCode = (short) ( level ++ );
@@ -1012,6 +1017,10 @@ public class TypeImpl implements Type, C
     return hasRefFeature;
   }
   
+  public int getNbrOfLongOrDoubleFeatures() {
+    return nbrOfLongOrDoubleFeatures;
+  }
+  
   /**
    * @return true if this type is an array of specific (not TOP) Feature structures, not FSArray
    */