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 2017/09/04 16:52:00 UTC

svn commit: r1807254 - in /uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl: CASImpl.java SelectFSs_impl.java

Author: schor
Date: Mon Sep  4 16:52:00 2017
New Revision: 1807254

URL: http://svn.apache.org/viewvc?rev=1807254&view=rev
Log:
[UIMA-5548] support for emptyXXArray, removing of now unused JCas shared view things

Modified:
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SelectFSs_impl.java

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=1807254&r1=1807253&r2=1807254&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Mon Sep  4 16:52:00 2017
@@ -485,6 +485,16 @@ public class CASImpl extends AbstractCas
     private EmptyFloatList emptyFloatList;
     private EmptyIntegerList emptyIntegerList;
     private EmptyStringList emptyStringList;
+    
+    private FloatArray emptyFloatArray;
+    private FSArray emptyFSArray;
+    private IntegerArray emptyIntegerArray;
+    private StringArray emptyStringArray;
+    private DoubleArray emptyDoubleArray;
+    private LongArray emptyLongArray;
+    private ShortArray emptyShortArray;
+    private ByteArray emptyByteArray;
+    private BooleanArray emptyBooleanArray;
 
     /**
      * Created at startup time, lives as long as the CAS lives
@@ -526,9 +536,7 @@ public class CASImpl extends AbstractCas
     private final IntVector id2addr = traceFSs ? new IntVector() : null;
     private int nextId2Addr = 1;  // only for tracing, to convert id's to v2 addresses
     final private int initialHeapSize;
-    
-    JCasImpl.JCasSharedView jcasSharedView;
-    
+        
     private SharedViewData(CASImpl baseCAS, int initialHeapSize, TypeSystemImpl tsi) {
       this.baseCAS = baseCAS;
       this.tsi = tsi;
@@ -569,14 +577,21 @@ public class CASImpl extends AbstractCas
         id2addr.add(0);
         nextId2Addr = 1;
       }
-      if (jcasSharedView != null) {
-        jcasSharedView.reset();
-      }
       
       emptyFloatList = null; // these cleared in case new ts redefines?
       emptyFSList = null;
       emptyIntegerList = null;
       emptyStringList = null;
+      
+      emptyFloatArray = null;
+      emptyFSArray = null;
+      emptyIntegerArray = null;
+      emptyStringArray = null;
+      emptyDoubleArray = null;
+      emptyLongArray = null;
+      emptyShortArray = null;
+      emptyByteArray = null;
+      emptyBooleanArray = null;
   
       clearNonSharedInstanceData();
     }
@@ -1150,17 +1165,9 @@ public class CASImpl extends AbstractCas
   }
  
   private TOP createFsFromGenerator(FsGenerator3[] gs, TypeImpl ti) {
-//    if (ti == null || gs == null || gs[ti.getCode()] == null) {
-//      System.out.println("debug");
-//    }
     return gs[ti.getCode()].createFS(ti, this);
   }
   
-//  public int ll_createFSAnnotCheck(int typeCode) {
-//    TOP fs = createFSAnnotCheck(getTypeFromCode(typeCode));
-//    svd.id2fs.put(fs);  // required for low level, in order to "hold onto" / prevent GC of FS
-//    return fs._id;
-//  }
   
   public TOP createArray(TypeImpl array_type, int arrayLength) {
     TypeImpl_array tia = (TypeImpl_array) array_type;
@@ -1176,15 +1183,19 @@ public class CASImpl extends AbstractCas
       case longTypeCode: return new LongArray(array_type, this, arrayLength);
       case doubleTypeCode: return new DoubleArray(array_type, this, arrayLength);
       case stringTypeCode: return new StringArray(array_type, this, arrayLength);
-//      case javaObjectTypeCode: return new JavaObjectArray(array_type, this, arrayLength);
-      default: Misc.internalError();
+      default: throw Misc.internalError();
       }
-//      return tia.getGeneratorArray().createFS(type, this, arrayLength); 
-//      return (((FsGeneratorArray)getFsGenerator(type.getCode())).createFS(type, this, arrayLength));
     }
     return (TOP) createArrayFS(array_type, arrayLength);
   }
 
+  /* 
+   * ===============  These methods might be deprecated in favor of
+   *                  new FSArray(jcas, length) etc.
+   *                  except that these run with the CAS, not JCas 
+   * (non-Javadoc)
+   * @see org.apache.uima.cas.CAS#createArrayFS(int)
+   */
   @Override
   public ArrayFS createArrayFS(int length) {
     return createArrayFS(getTypeSystemImpl().fsArrayType, length);
@@ -1193,8 +1204,6 @@ public class CASImpl extends AbstractCas
   private ArrayFS createArrayFS(TypeImpl type, int length) {
     checkArrayPreconditions(length);
     return new FSArray(type, this, length);         
-//        getTypeSystemImpl().fsArrayType.getGeneratorArray()         // (((FsGeneratorArray)getFsGenerator(fsArrayTypeCode))
-//        .createFS(type, this, length);
   }
   
   @Override
@@ -1215,11 +1224,6 @@ public class CASImpl extends AbstractCas
     return new StringArray(getTypeSystemImpl().stringArrayType, this, length);
   }
   
-//  public JavaObjectArray createJavaObjectArrayFS(int length) {
-//    checkArrayPreconditions(length);
-//    return new JavaObjectArray(getTypeSystemImpl().javaObjectArrayType, this, length);
-//  }
-
 
   // return true if only one sofa and it is the default text sofa
   public boolean isBackwardCompatibleCas() {
@@ -2095,7 +2099,6 @@ public class CASImpl extends AbstractCas
   public JCas getJCas() {
     if (this.jcas == null) {
       this.jcas = JCasImpl.getJCas(this);
-      this.svd.jcasSharedView = jcas.getSharedView();
     }
     return this.jcas;
   }
@@ -4748,64 +4751,130 @@ public class CASImpl extends AbstractCas
     }
   }
 
-  public EmptyFSList getEmptyFSListImpl() {
+  public EmptyFSList getEmptyFSList() {
     if (null == svd.emptyFSList) {
       svd.emptyFSList = new EmptyFSList(getTypeSystemImpl().fsEListType, this);
     }
     return svd.emptyFSList;
   }
 
-  public EmptyFloatList getEmptyFloatListImpl() {
+  /*
+   * @see org.apache.uima.cas.CAS#getEmptyFloatList()
+   */
+  public EmptyFloatList getEmptyFloatList() {
     if (null == svd.emptyFloatList) {
       svd.emptyFloatList = new EmptyFloatList(getTypeSystemImpl().floatEListType, this);
     }
     return svd.emptyFloatList;
   }
   
-  public EmptyIntegerList getEmptyIntegerListImpl() {
+  public EmptyIntegerList getEmptyIntegerList() {
     if (null == svd.emptyIntegerList) {
       svd.emptyIntegerList = new EmptyIntegerList(getTypeSystemImpl().intEListType, this);
     }
     return svd.emptyIntegerList;
   }
   
-  public EmptyStringList getEmptyStringListImpl() {
+  public EmptyStringList getEmptyStringList() {
     if (null == svd.emptyStringList) {
       svd.emptyStringList = new EmptyStringList(getTypeSystemImpl().stringEListType, this);
     }
     return svd.emptyStringList;
   }
   
+  public FloatArray getEmptyFloatArray() {
+    if (null == svd.emptyFloatArray) {
+      svd.emptyFloatArray = new FloatArray(this.getJCas(), 0);
+    }
+    return svd.emptyFloatArray;
+  }
+
+  public FSArray getEmptyFSArray() {
+    if (null == svd.emptyFSArray) {
+      svd.emptyFSArray = new FSArray(this.getJCas(), 0);
+    }
+    return svd.emptyFSArray;
+  }
+  
+  public IntegerArray getEmptyIntegerArray() {
+    if (null == svd.emptyIntegerArray) {
+      svd.emptyIntegerArray = new IntegerArray(this.getJCas(), 0);
+    }
+    return svd.emptyIntegerArray;
+  }
+  
+  public StringArray getEmptyStringArray() {
+    if (null == svd.emptyStringArray) {
+      svd.emptyStringArray = new StringArray(this.getJCas(), 0);
+    }
+    return svd.emptyStringArray;
+  }
+  
+  public DoubleArray getEmptyDoubleArray() {
+    if (null == svd.emptyDoubleArray) {
+      svd.emptyDoubleArray = new DoubleArray(this.getJCas(), 0);
+    }
+    return svd.emptyDoubleArray;
+  }
+  
+  public LongArray getEmptyLongArray() {
+    if (null == svd.emptyLongArray) {
+      svd.emptyLongArray = new LongArray(this.getJCas(), 0);
+    }
+    return svd.emptyLongArray;
+  }
+  
+  public ShortArray getEmptyShortArray() {
+    if (null == svd.emptyShortArray) {
+      svd.emptyShortArray = new ShortArray(this.getJCas(), 0);
+    }
+    return svd.emptyShortArray;
+  }
+  
+  public ByteArray getEmptyByteArray() {
+    if (null == svd.emptyByteArray) {
+      svd.emptyByteArray = new ByteArray(this.getJCas(), 0);
+    }
+    return svd.emptyByteArray;
+  }
+  
+  public BooleanArray getEmptyBooleanArray() {
+    if (null == svd.emptyBooleanArray) {
+      svd.emptyBooleanArray = new BooleanArray(this.getJCas(), 0);
+    }
+    return svd.emptyBooleanArray;
+  }
+  
   /**
    * @param rangeCode special codes for serialization use only
    * @return the empty list (shared) corresponding to the type
    */
   public EmptyList getEmptyList(int rangeCode) {
-    return (rangeCode == CasSerializerSupport.TYPE_CLASS_INTLIST) ? getEmptyIntegerListImpl() :
-           (rangeCode == CasSerializerSupport.TYPE_CLASS_FLOATLIST) ? getEmptyFloatListImpl() :
-           (rangeCode == CasSerializerSupport.TYPE_CLASS_STRINGLIST) ? getEmptyStringListImpl() :
-                                                                       getEmptyFSListImpl();
+    return (rangeCode == CasSerializerSupport.TYPE_CLASS_INTLIST) ? getEmptyIntegerList() :
+           (rangeCode == CasSerializerSupport.TYPE_CLASS_FLOATLIST) ? getEmptyFloatList() :
+           (rangeCode == CasSerializerSupport.TYPE_CLASS_STRINGLIST) ? getEmptyStringList() :
+                                                                       getEmptyFSList();
   }
   
   /**
    * Get an empty list from the type code of a list
-   * @param rangeCode -
+   * @param typeCode -
    * @return -
    */
-  public EmptyList getEmptyListFromTypeCode(int rangeCode) {
-    switch (rangeCode) {
+  public EmptyList getEmptyListFromTypeCode(int typeCode) {
+    switch (typeCode) {
     case fsListTypeCode:
     case fsEListTypeCode:
-    case fsNeListTypeCode: return getEmptyFSListImpl();
+    case fsNeListTypeCode: return getEmptyFSList();
     case floatListTypeCode:
     case floatEListTypeCode:
-    case floatNeListTypeCode: return getEmptyFloatListImpl();
+    case floatNeListTypeCode: return getEmptyFloatList();
     case intListTypeCode:
     case intEListTypeCode:
-    case intNeListTypeCode: return getEmptyIntegerListImpl();
+    case intNeListTypeCode: return getEmptyIntegerList();
     case stringListTypeCode:
     case stringEListTypeCode:
-    case stringNeListTypeCode: return getEmptyStringListImpl();
+    case stringNeListTypeCode: return getEmptyStringList();
     default: throw new IllegalArgumentException();
     }
   }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SelectFSs_impl.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SelectFSs_impl.java?rev=1807254&r1=1807253&r2=1807254&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SelectFSs_impl.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SelectFSs_impl.java Mon Sep  4 16:52:00 2017
@@ -97,6 +97,7 @@ public class SelectFSs_impl <T extends F
   private final static boolean IS_UNORDERED = true;
   private final static boolean IS_ORDERED = false;
   private final static boolean IS_UNAMBIGUOUS = false;
+  private final static boolean IS_NOT_STRICT = false;
   
   private CASImpl view;
   private JCasImpl jcas;
@@ -111,7 +112,7 @@ public class SelectFSs_impl <T extends F
   private boolean isTypePriority = false;
 //  private boolean isPositionUsesType = false;
   private boolean isSkipSameBeginEndType = false; // for boundsUse only
-  private boolean isNonOverlapping = false;
+  private boolean isNonOverlapping = IS_UNAMBIGUOUS;
   private boolean isIncludeAnnotBeyondBounds = false;
   private boolean isAllViews = false;
   private boolean isNullOK = false;
@@ -715,7 +716,7 @@ public class SelectFSs_impl <T extends F
         //     - orderNotNecessary / 
 
         it = (isAnnotationIndex) 
-               ? (LowLevelIterator<T>) ai.iterator( ! isNonOverlapping, false /* because unbounded */, isUnordered, ! isTypePriority)
+               ? (LowLevelIterator<T>) ai.iterator( ! isNonOverlapping, IS_NOT_STRICT /* because unbounded */, isUnordered, ! isTypePriority)
                : idx.iterator(isUnordered, ! isTypePriority);
       }
     } else {