Package org.apache.uima.cas.impl
Class BinaryCasSerDes4.Serializer
java.lang.Object
org.apache.uima.cas.impl.BinaryCasSerDes4.Serializer
- Enclosing class:
- BinaryCasSerDes4
Class instantiated once per serialization
Multiple serializations in parallel supported, with
multiple instances of this
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Modified Values Output: For each FS that has 1 or more modified values, write the heap addr of the FS For all modified values within the FS: if it is an aux array element, write the index in the aux array and the new value otherwise, write the slot offset and the new value -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataOutputStream
private final ByteArrayOutputStream[]
private final DataOutputStream
private final ByteHeap
private final CASImpl
private final BinaryCasSerDes4.CompressLevel
private final BinaryCasSerDes4.CompressStrat
private final DataOutputStream
private final boolean
private final DataOutputStream[]
private final DataOutputStream
private final DataOutputStream
private final int[]
private final DataOutputStream
private final DataOutputStream
private final DataOutputStream
private final BinaryCasSerDes4.ComprItemRefs
private final int[]
private final int
private final DataOutputStream
private int
private final DataOutputStream
private int
private final boolean
private final DataOutputStream
private final DataOutputStream
private final LongHeap
private final MarkerImpl
private boolean
private final OptimizeStrings
private final DataOutputStream
private final Integer[]
private final DataOutputStream
private final ShortHeap
private final SerializationMeasures
private final DataOutputStream
private final StringHeap
private final DataOutputStream
private final DataOutputStream
private final DataOutputStream
private final DataOutputStream
private final int[]
private BinaryCasSerDes4.TypeInfo
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Serializer
(CASImpl cas, DataOutputStream serializedOut, MarkerImpl mark, SerializationMeasures sm, BinaryCasSerDes4.CompressLevel compressLevel, BinaryCasSerDes4.CompressStrat compressStrategy) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Method: write with deflation into a single byte array stream skip if not worth deflating skip the Slot_Control stream record in the Slot_Control stream, for each deflated stream: the Slot index the number of compressed bytes the number of uncompressed bytes add to header: nbr of compressed entries the Slot_Control stream size the Slot_Control stream all the zipped streamsprivate int
compressFsxPart
(int[] fsIndexes, int fsNdxStart) private int
encodeIntSign
(int v) private void
private int
serializeArrayLength
(int iHeap) private void
serializeByKind
(int iHeap, int offset) private void
serializeDiffWithPrevTypeSlot
(BinaryCasSerDes4.SlotKind kind, int iHeap, int offset) private void
serializeHeapStoredArray
(int iHeap) private void
private void
serializeNonHeapStoredArray
(int iHeap) setupOutputStream
(int i) private void
private void
writeDiff
(int kind, int v, int prev) Encoding: bit 6 = sign: 1 = negative bit 7 = delta: 1 = deltaprivate void
writeDouble
(long raw) private void
writeFloat
(int raw) Need to support NAN sets, 0x7fc....private void
writeFromByteArray
(BinaryCasSerDes4.SlotKind kind, int startPos, int length) private void
writeFromLongArray
(BinaryCasSerDes4.SlotKind kind, int startPos, int length) private void
writeFromShortArray
(int startPos, int length) private int
writeIntOrHeapRef
(int kind, int index, int prev) private void
writeLong
(long v, long prev) private long
writeLongFromHeapIndex
(int index, long prev) private void
String encoding Length = 0 - used for null, no offset written Length = 1 - used for "", no offset written Length > 0 (subtract 1): used for actual string length Length < 0 - use (-length) as slot index (minimum is 1, slot 0 is NULL) For length > 0, write also the offset.private void
writeUnsignedByte
(DataOutputStream s, int v) private void
writeVnumber
(int kind, int v) private void
writeVnumber
(int kind, long v) private void
writeVnumber
(DataOutputStream s, int v) private void
writeVnumber
(DataOutputStream s, long v)
-
Field Details
-
serializedOut
-
cas
-
mark
-
sm
-
baosZipSources
-
dosZipSources
-
heap
private final int[] heap -
heapStart
private int heapStart -
heapEnd
private final int heapEnd -
stringHeapObj
-
longHeapObj
-
shortHeapObj
-
byteHeapObj
-
isDelta
private final boolean isDelta -
doMeasurement
private final boolean doMeasurement -
fsStartIndexes
-
typeCodeHisto
private final int[] typeCodeHisto -
serializedTypeCode2Code
-
estimatedZipSize
private final int[] estimatedZipSize -
os
-
compressLevel
-
compressStrategy
-
typeInfo
-
iPrevHeap
private int iPrevHeap -
only1CommonString
private boolean only1CommonString -
arrayLength_dos
-
heapRef_dos
-
int_dos
-
byte_dos
-
short_dos
-
typeCode_dos
-
strOffset_dos
-
strLength_dos
-
long_High_dos
-
long_Low_dos
-
float_Mantissa_Sign_dos
-
float_Exponent_dos
-
double_Mantissa_Sign_dos
-
double_Exponent_dos
-
fsIndexes_dos
-
strChars_dos
-
control_dos
-
strSeg_dos
-
-
Constructor Details
-
Serializer
private Serializer(CASImpl cas, DataOutputStream serializedOut, MarkerImpl mark, SerializationMeasures sm, BinaryCasSerDes4.CompressLevel compressLevel, BinaryCasSerDes4.CompressStrat compressStrategy)
-
-
Method Details
-
setupOutputStreams
private void setupOutputStreams() -
serialize
- Throws:
IOException
-
serializeIndexedFeatureStructures
- Throws:
IOException
-
compressFsxPart
- Throws:
IOException
-
serializeHeapStoredArray
- Throws:
IOException
-
writeIntOrHeapRef
- Throws:
IOException
-
writeLongFromHeapIndex
- Throws:
IOException
-
serializeNonHeapStoredArray
- Throws:
IOException
-
serializeByKind
- Throws:
IOException
-
serializeArrayLength
- Throws:
IOException
-
serializeDiffWithPrevTypeSlot
private void serializeDiffWithPrevTypeSlot(BinaryCasSerDes4.SlotKind kind, int iHeap, int offset) throws IOException - Throws:
IOException
-
collectAndZip
Method: write with deflation into a single byte array stream skip if not worth deflating skip the Slot_Control stream record in the Slot_Control stream, for each deflated stream: the Slot index the number of compressed bytes the number of uncompressed bytes add to header: nbr of compressed entries the Slot_Control stream size the Slot_Control stream all the zipped streams- Throws:
IOException
- passthru
-
setupOutputStream
-
writeLong
- Throws:
IOException
-
writeString
String encoding Length = 0 - used for null, no offset written Length = 1 - used for "", no offset written Length > 0 (subtract 1): used for actual string length Length < 0 - use (-length) as slot index (minimum is 1, slot 0 is NULL) For length > 0, write also the offset.- Throws:
IOException
- passthru
-
writeFloat
Need to support NAN sets, 0x7fc.... for NAN 0xff8.... for NAN, negative infinity 0x7f8 for NAN, positive infinity Because 0 occurs frequently, we reserve exp of 0 for the value 0- Parameters:
raw
- the number to write- Throws:
IOException
-
writeVnumber
- Throws:
IOException
-
writeVnumber
- Throws:
IOException
-
writeVnumber
- Throws:
IOException
-
writeVnumber
- Throws:
IOException
-
writeUnsignedByte
- Throws:
IOException
-
writeDouble
- Throws:
IOException
-
encodeIntSign
private int encodeIntSign(int v) -
writeDiff
Encoding: bit 6 = sign: 1 = negative bit 7 = delta: 1 = delta- Parameters:
kind
- the kind of sloti
- runs from iHeap + 3 to end of array- Throws:
IOException
- passthru
-
writeFromByteArray
private void writeFromByteArray(BinaryCasSerDes4.SlotKind kind, int startPos, int length) throws IOException - Throws:
IOException
-
writeFromLongArray
private void writeFromLongArray(BinaryCasSerDes4.SlotKind kind, int startPos, int length) throws IOException - Throws:
IOException
-
writeFromShortArray
- Throws:
IOException
-