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 2013/02/05 20:18:16 UTC

svn commit: r1442700 [1/3] - in /uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl: BinaryCasSerDes4.java BinaryCasSerDes5.java CasTypeSystemMapper.java TypeSystemImpl.java

Author: schor
Date: Tue Feb  5 19:18:15 2013
New Revision: 1442700

URL: http://svn.apache.org/viewvc?rev=1442700&view=rev
Log:
[UIMA-2498] finish delta cas deser with mapping; move new style to BinaryCasSerDes5, rework BinaryCasSerDes4 to work with ..5 (keeping 4 for deserializing the older zip format).

Added:
    uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes5.java   (with props)
Modified:
    uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java
    uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/CasTypeSystemMapper.java
    uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java

Modified: uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java?rev=1442700&r1=1442699&r2=1442700&view=diff
==============================================================================
--- uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java (original)
+++ uima/uimaj/branches/filteredCompress-uima-2498/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java Tue Feb  5 19:18:15 2013
@@ -19,32 +19,32 @@
 
 package org.apache.uima.cas.impl;
 
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.NBR_SLOT_KIND_ZIP_STREAMS;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_ArrayLength;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_BooleanRef;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Byte;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_ByteRef;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Control;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_DoubleRef;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Double_Exponent;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Double_Mantissa_Sign;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Float_Exponent;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Float_Mantissa_Sign;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_FsIndexes;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_HeapRef;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Int;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_LongRef;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Long_High;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Long_Low;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_MainHeap;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_Short;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_ShortRef;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrChars;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrLength;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrOffset;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrRef;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_StrSeg;
-import static org.apache.uima.cas.impl.BinaryCasSerDes4.SlotKind.Slot_TypeCode;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.NBR_SLOT_KIND_ZIP_STREAMS;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_ArrayLength;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_BooleanRef;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Byte;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_ByteRef;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Control;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_DoubleRef;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Double_Exponent;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Double_Mantissa_Sign;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Float_Exponent;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Float_Mantissa_Sign;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_FsIndexes;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_HeapRef;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Int;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_LongRef;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Long_High;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Long_Low;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_MainHeap;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_Short;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_ShortRef;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_StrChars;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_StrLength;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_StrOffset;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_StrRef;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_StrSeg;
+import static org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind.Slot_TypeCode;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -73,6 +73,9 @@ import java.util.zip.InflaterInputStream
 import org.apache.uima.cas.AbstractCas;
 import org.apache.uima.cas.CASRuntimeException;
 import org.apache.uima.cas.Marker;
+import org.apache.uima.cas.impl.BinaryCasSerDes5.CompressLevel;
+import org.apache.uima.cas.impl.BinaryCasSerDes5.CompressStrat;
+import org.apache.uima.cas.impl.BinaryCasSerDes5.SlotKind;
 import org.apache.uima.cas.impl.TypeSystemImpl.TypeInfo;
 import org.apache.uima.internal.util.IntVector;
 import org.apache.uima.jcas.JCas;
@@ -198,98 +201,98 @@ public class BinaryCasSerDes4 {
    *     which can make for fewer bytes to represent the number.
    */
 
-  /**
-   * Compression alternatives
-   */
-  
-  public enum CompressLevel {
-    None(   Deflater.NO_COMPRESSION),
-    Fast(   Deflater.BEST_SPEED),
-    Default(Deflater.DEFAULT_COMPRESSION),
-    Best(   Deflater.BEST_COMPRESSION),
-    ;
-    final public int lvl;
-    CompressLevel(int lvl) {
-      this.lvl = lvl;
-    }
-  }
-  
-  public enum CompressStrat {
-    Default(      Deflater.DEFAULT_STRATEGY),
-    Filtered(     Deflater.FILTERED),
-    HuffmanOnly(  Deflater.HUFFMAN_ONLY),
-    ;
-    final public int strat;
-    CompressStrat(int strat) {
-      this.strat = strat;
-    }
-  }
-  
-  /**
-   * Define all the slot kinds.
-   */
-  public enum SlotKind {
-    Slot_ArrayLength(! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
-    Slot_HeapRef(    IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
-    Slot_Int(        IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
-    Slot_Byte(       ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
-    Slot_Short(      IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
-    Slot_TypeCode(   ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
-
-    Slot_StrOffset(  ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, !IN_MAIN_HEAP),
-    Slot_StrLength(  ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, !IN_MAIN_HEAP),
-    Slot_Long_High(    IS_DIFF_ENCODE,           IGNORED, 0, !IN_MAIN_HEAP),
-    Slot_Long_Low (    IS_DIFF_ENCODE,           IGNORED, 0, !IN_MAIN_HEAP),
-
-    // the next are not actual slot kinds, but instead
-    // are codes used to control encoding of Floats and Doubles.
-    Slot_Float_Mantissa_Sign( ! IS_DIFF_ENCODE, CAN_BE_NEGATIVE, 0, !IN_MAIN_HEAP),
-    // exponent is 8 bits, and shifted in the expectation
-    // that many values may be between 1 and 0 (e.g., normalized values)
-    //   -- so sign moving is needed
-    Slot_Float_Exponent(      ! IS_DIFF_ENCODE, CAN_BE_NEGATIVE, 0, !IN_MAIN_HEAP),
-    
-    Slot_Double_Mantissa_Sign(! IS_DIFF_ENCODE, CAN_BE_NEGATIVE, 0, !IN_MAIN_HEAP),
-    Slot_Double_Exponent(     ! IS_DIFF_ENCODE, CAN_BE_NEGATIVE, 0, !IN_MAIN_HEAP),
-    Slot_FsIndexes(             IS_DIFF_ENCODE,         IGNORED, 4, !IN_MAIN_HEAP),
-    
-    Slot_StrChars(            IGNORED,          IGNORED, 2, !IN_MAIN_HEAP),
-    
-    Slot_Control(             IGNORED,          IGNORED, 0, !IN_MAIN_HEAP),
-    Slot_StrSeg(              ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 0, ! IN_MAIN_HEAP),
-    
-    // the next slots are not serialized
-    Slot_StrRef(     IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
-    Slot_BooleanRef( ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
-    Slot_ByteRef(    IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
-    Slot_ShortRef(   IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
-    Slot_LongRef(    IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
-    Slot_DoubleRef(  IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
-    Slot_Float(      ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
-    Slot_Boolean(    ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
-    // next used to capture original heap size
-    Slot_MainHeap(   IGNORED,          IGNORED,           4, !IN_MAIN_HEAP),
-
-    ;
-
-    public final boolean isDiffEncode;
-    public final boolean canBeNegative;
-    public final boolean inMainHeap;
-    public final int elementSize;
-    
-    public static final int NBR_SLOT_KIND_ZIP_STREAMS;
-    static {NBR_SLOT_KIND_ZIP_STREAMS = Slot_StrRef.ordinal();}
-    
-    SlotKind(boolean isDiffEncode, 
-             boolean canBeNegative, 
-             int elementSize,
-             boolean inMainHeap) {
-      this.isDiffEncode = isDiffEncode;
-      this.canBeNegative = isDiffEncode ? true : canBeNegative;
-      this.elementSize = elementSize; 
-      this.inMainHeap = inMainHeap;
-    }
-  }
+//  /**
+//   * Compression alternatives
+//   */
+//  
+//  public enum CompressLevel {
+//    None(   Deflater.NO_COMPRESSION),
+//    Fast(   Deflater.BEST_SPEED),
+//    Default(Deflater.DEFAULT_COMPRESSION),
+//    Best(   Deflater.BEST_COMPRESSION),
+//    ;
+//    final public int lvl;
+//    CompressLevel(int lvl) {
+//      this.lvl = lvl;
+//    }
+//  }
+//  
+//  public enum CompressStrat {
+//    Default(      Deflater.DEFAULT_STRATEGY),
+//    Filtered(     Deflater.FILTERED),
+//    HuffmanOnly(  Deflater.HUFFMAN_ONLY),
+//    ;
+//    final public int strat;
+//    CompressStrat(int strat) {
+//      this.strat = strat;
+//    }
+//  }
+//  
+//  /**
+//   * Define all the slot kinds.
+//   */
+//  public enum SlotKind {
+//    Slot_ArrayLength(! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
+//    Slot_HeapRef(    IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
+//    Slot_Int(        IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
+//    Slot_Byte(       ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
+//    Slot_Short(      IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
+//    Slot_TypeCode(   ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
+//
+//    Slot_StrOffset(  ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, !IN_MAIN_HEAP),
+//    Slot_StrLength(  ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, !IN_MAIN_HEAP),
+//    Slot_Long_High(    IS_DIFF_ENCODE,           IGNORED, 0, !IN_MAIN_HEAP),
+//    Slot_Long_Low (    IS_DIFF_ENCODE,           IGNORED, 0, !IN_MAIN_HEAP),
+//
+//    // the next are not actual slot kinds, but instead
+//    // are codes used to control encoding of Floats and Doubles.
+//    Slot_Float_Mantissa_Sign( ! IS_DIFF_ENCODE, CAN_BE_NEGATIVE, 0, !IN_MAIN_HEAP),
+//    // exponent is 8 bits, and shifted in the expectation
+//    // that many values may be between 1 and 0 (e.g., normalized values)
+//    //   -- so sign moving is needed
+//    Slot_Float_Exponent(      ! IS_DIFF_ENCODE, CAN_BE_NEGATIVE, 0, !IN_MAIN_HEAP),
+//    
+//    Slot_Double_Mantissa_Sign(! IS_DIFF_ENCODE, CAN_BE_NEGATIVE, 0, !IN_MAIN_HEAP),
+//    Slot_Double_Exponent(     ! IS_DIFF_ENCODE, CAN_BE_NEGATIVE, 0, !IN_MAIN_HEAP),
+//    Slot_FsIndexes(             IS_DIFF_ENCODE,         IGNORED, 4, !IN_MAIN_HEAP),
+//    
+//    Slot_StrChars(            IGNORED,          IGNORED, 2, !IN_MAIN_HEAP),
+//    
+//    Slot_Control(             IGNORED,          IGNORED, 0, !IN_MAIN_HEAP),
+//    Slot_StrSeg(              ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 0, ! IN_MAIN_HEAP),
+//    
+//    // the next slots are not serialized
+//    Slot_StrRef(     IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
+//    Slot_BooleanRef( ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
+//    Slot_ByteRef(    IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
+//    Slot_ShortRef(   IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
+//    Slot_LongRef(    IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
+//    Slot_DoubleRef(  IS_DIFF_ENCODE,             IGNORED, 4, IN_MAIN_HEAP),
+//    Slot_Float(      ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
+//    Slot_Boolean(    ! IS_DIFF_ENCODE, ! CAN_BE_NEGATIVE, 4, IN_MAIN_HEAP),
+//    // next used to capture original heap size
+//    Slot_MainHeap(   IGNORED,          IGNORED,           4, !IN_MAIN_HEAP),
+//
+//    ;
+//
+//    public final boolean isDiffEncode;
+//    public final boolean canBeNegative;
+//    public final boolean inMainHeap;
+//    public final int elementSize;
+//    
+//    public static final int NBR_SLOT_KIND_ZIP_STREAMS;
+//    static {NBR_SLOT_KIND_ZIP_STREAMS = Slot_StrRef.ordinal();}
+//    
+//    SlotKind(boolean isDiffEncode, 
+//             boolean canBeNegative, 
+//             int elementSize,
+//             boolean inMainHeap) {
+//      this.isDiffEncode = isDiffEncode;
+//      this.canBeNegative = isDiffEncode ? true : canBeNegative;
+//      this.elementSize = elementSize; 
+//      this.inMainHeap = inMainHeap;
+//    }
+//  }
   
   // speedups
   final private static int arrayLength_i = Slot_ArrayLength.ordinal();