Package org.apache.uima.cas.impl
Class BinaryCasSerDes4
- java.lang.Object
-
- org.apache.uima.cas.impl.BinaryCasSerDes4
-
- All Implemented Interfaces:
SlotKindsConstants
public class BinaryCasSerDes4 extends java.lang.Object implements SlotKindsConstants
User callable serialization and deserialization of the CAS in a compressed Binary Format This serializes/deserializes the state of the CAS, assuming that the type information remains constant. Header specifies to reader the format, and the compression level. How to Serialize: 1) create an instance of this class, specifying some options that don't change very much 2) call serialize(CAS) to serialize the cas * You can reuse the instance for a different CAS (as long as the type system is the same); this will save setup time. This class lazily constructs customized TypeInfo instances for each type encountered in serializing. These are preserved across multiple serialization calls, so their setup / initialization is only needed the first time. The form of the binary CAS is inserted at the beginning so that receivers can do the proper deserialization. Binary format requires that the exact same type system be used when deserializing How to Deserialize: 1) get an appropriate CAS to deserialize into. For delta CAS, it does not have to be empty. 2) call CASImpl: cas.reinit(inputStream) This is the existing method for binary deserialization, and it now handles this compressed version, too. Delta cas is also supported. Compression/Decompression Works in two stages: application of Zip/Unzip to particular sub-collections of CAS data, grouped according to similar data distribution collection of like kinds of data (to make the zipping more effective) There can be up to ~20 of these collections, such as control info, float-exponents, string chars Deserialization: Read all bytes, create separate ByteArrayInputStreams for each segment, sharing byte bfr create appropriate unzip data input streams for these Properties of Form 4: 1) (Change from V2) Indexes are used to determine what gets serialized, because there's no "heap" to walk, unless the v2-id-mode is in effect. 2) The number used for references to FSs is a sequentially incrementing one, starting at 1 This allows better compression.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BinaryCasSerDes4.Compression
static class
BinaryCasSerDes4.CompressLevel
Compression alternativesstatic class
BinaryCasSerDes4.CompressStrat
private class
BinaryCasSerDes4.Deserializer
Class instantiated once per deserialization Multiple deserializations in parallel supported, with multiple instances of thisprivate class
BinaryCasSerDes4.Serializer
Class instantiated once per serialization Multiple serializations in parallel supported, with multiple instances of this
-
Field Summary
Fields Modifier and Type Field Description static boolean
CAN_BE_NEGATIVE
private boolean
doMeasurements
(package private) TypeImpl
fsArrayType
static boolean
IGNORED
static boolean
IN_MAIN_HEAP
static boolean
IS_DIFF_ENCODE
private static boolean
TRACE_DES
private static boolean
TRACE_DOUBLE
private static boolean
TRACE_SER
private TypeSystemImpl
ts
Things set up for one instance of this class, and reuse-ablestatic int
TYPECODE_COMPR
-
Fields inherited from interface org.apache.uima.cas.impl.SlotKindsConstants
arrayLength_i, byte_i, control_i, double_Exponent_i, double_Mantissa_Sign_i, float_Exponent_i, float_Mantissa_Sign_i, fsIndexes_i, heapRef_i, int_i, long_High_i, long_Low_i, NBR_SLOT_KIND_ZIP_STREAMS, short_i, strChars_i, strLength_i, strOffset_i, strSeg_i, typeCode_i
-
-
Constructor Summary
Constructors Constructor Description BinaryCasSerDes4(TypeSystemImpl ts, boolean doMeasurements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deserialize(CASImpl cas, java.io.InputStream deserIn, boolean isDelta, CommonSerDes.Header h)
static void
dumpCas(CASImpl cas)
(package private) static CommonSerDesSequential
getCsds(CASImpl cas, boolean isDelta)
private static java.io.DataOutputStream
makeDataOutputStream(java.lang.Object f)
SerializationMeasures
serialize(AbstractCas cas, java.lang.Object out)
SerializationMeasures
serialize(AbstractCas cas, java.lang.Object out, Marker trackingMark)
SerializationMeasures
serialize(AbstractCas cas, java.lang.Object out, Marker trackingMark, BinaryCasSerDes4.CompressLevel compressLevel)
SerializationMeasures
serialize(AbstractCas cas, java.lang.Object out, Marker trackingMark, BinaryCasSerDes4.CompressLevel compressLevel, BinaryCasSerDes4.CompressStrat compressStrategy)
void
serializeWithTsi(CASImpl casImpl, java.lang.Object out)
-
-
-
Field Detail
-
TRACE_SER
private static final boolean TRACE_SER
- See Also:
- Constant Field Values
-
TRACE_DES
private static final boolean TRACE_DES
- See Also:
- Constant Field Values
-
TRACE_DOUBLE
private static final boolean TRACE_DOUBLE
- See Also:
- Constant Field Values
-
TYPECODE_COMPR
public static final int TYPECODE_COMPR
- See Also:
- Constant Field Values
-
IS_DIFF_ENCODE
public static final boolean IS_DIFF_ENCODE
- See Also:
- Constant Field Values
-
CAN_BE_NEGATIVE
public static final boolean CAN_BE_NEGATIVE
- See Also:
- Constant Field Values
-
IGNORED
public static final boolean IGNORED
- See Also:
- Constant Field Values
-
IN_MAIN_HEAP
public static final boolean IN_MAIN_HEAP
- See Also:
- Constant Field Values
-
ts
private final TypeSystemImpl ts
Things set up for one instance of this class, and reuse-able
-
doMeasurements
private final boolean doMeasurements
-
fsArrayType
final TypeImpl fsArrayType
-
-
Constructor Detail
-
BinaryCasSerDes4
public BinaryCasSerDes4(TypeSystemImpl ts, boolean doMeasurements)
- Parameters:
ts
- the type systemdoMeasurements
- - normally set this to false.
-
-
Method Detail
-
serialize
public SerializationMeasures serialize(AbstractCas cas, java.lang.Object out, Marker trackingMark, BinaryCasSerDes4.CompressLevel compressLevel, BinaryCasSerDes4.CompressStrat compressStrategy) throws java.io.IOException
- Parameters:
cas
- CAS to serializeout
- output objecttrackingMark
- tracking mark (for delta serialization)compressLevel
- -compressStrategy
- -- Returns:
- null or serialization measurements (depending on setting of doMeasurements)
- Throws:
java.io.IOException
- if the marker is invalid
-
serializeWithTsi
public void serializeWithTsi(CASImpl casImpl, java.lang.Object out) throws java.io.IOException
- Throws:
java.io.IOException
-
serialize
public SerializationMeasures serialize(AbstractCas cas, java.lang.Object out, Marker trackingMark, BinaryCasSerDes4.CompressLevel compressLevel) throws java.io.IOException
- Throws:
java.io.IOException
-
serialize
public SerializationMeasures serialize(AbstractCas cas, java.lang.Object out, Marker trackingMark) throws java.io.IOException
- Throws:
java.io.IOException
-
serialize
public SerializationMeasures serialize(AbstractCas cas, java.lang.Object out) throws java.io.IOException
- Throws:
java.io.IOException
-
deserialize
public void deserialize(CASImpl cas, java.io.InputStream deserIn, boolean isDelta, CommonSerDes.Header h) throws java.io.IOException
- Throws:
java.io.IOException
-
makeDataOutputStream
private static java.io.DataOutputStream makeDataOutputStream(java.lang.Object f) throws java.io.FileNotFoundException
- Parameters:
f
- can be a DataOutputStream, an OutputStream a File- Returns:
- a data output stream
- Throws:
java.io.FileNotFoundException
- passthru
-
getCsds
static CommonSerDesSequential getCsds(CASImpl cas, boolean isDelta)
-
dumpCas
public static void dumpCas(CASImpl cas)
-
-