Package org.apache.uima.cas.impl
Class BinaryCasSerDes4.Deserializer
- java.lang.Object
-
- org.apache.uima.cas.impl.BinaryCasSerDes4.Deserializer
-
- Enclosing class:
- BinaryCasSerDes4
private class BinaryCasSerDes4.Deserializer extends java.lang.Object
Class instantiated once per deserialization Multiple deserializations in parallel supported, with multiple instances of this
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
BinaryCasSerDes4.Deserializer.ReadModifiedFSs
Modified Values Modified heap values need fsStartIndexes conversion
-
Field Summary
Fields Modifier and Type Field Description private java.io.DataInputStream
arrayLength_dis
private CASImpl
baseCas
private BinaryCasSerDes
bcsd
private java.io.DataInputStream
byte_dis
private java.io.DataInputStream
control_dis
private CommonSerDesSequential
csds
private TOP
currentFs
the FS being deserializedprivate java.io.DataInputStream[]
dataInputs
private java.io.DataInput
deserIn
private java.io.DataInputStream
double_Exponent_dis
private java.io.DataInputStream
double_Mantissa_Sign_dis
private java.util.List<java.lang.Runnable>
fixupsNeeded
the "fixups" for relative heap refs actions set slot valuesprivate java.io.DataInputStream
float_Exponent_dis
private java.io.DataInputStream
float_Mantissa_Sign_dis
private java.io.DataInputStream
fsIndexes_dis
private int
heapEnd
private java.io.DataInputStream
heapRef_dis
private int
heapStart
private java.util.zip.Inflater[]
inflaters
private java.io.DataInputStream
int_dis
private boolean
isDelta
private CASImpl
ivCas
private java.io.DataInputStream
long_High_dis
private java.io.DataInputStream
long_Low_dis
private boolean
only1CommonString
private TOP
prevFs
private TOP[]
prevFsByType
Used for differencing, except for HeapRef values which use aboveprivate int[]
prevFsRefs
private int[][]
prevFsRefsByType
For differencing when reading.private java.lang.String[]
readCommonString
private Int2ObjHashMap<TOP,TOP>
seq2fs
convert between FSs and "sequential" numbers Note: This may be identity map, but may not in the case for V3 where some FSs are GC'dprivate java.io.DataInputStream
short_dis
private java.util.List<java.lang.Runnable>
singleFsDefer
Deferred actions to set Feature Slots of feature structures.private java.lang.String
sofaName
private int
sofaNum
used for deferred creationprivate Sofa
sofaRef
private java.io.DataInputStream
strChars_dis
private StringHeap
stringHeapObj
private java.io.DataInputStream
strLength_dis
private java.io.DataInputStream
strOffset_dis
private java.io.DataInputStream
strSeg_dis
private java.io.DataInputStream
typeCode_dis
private java.util.List<java.lang.Runnable>
uimaSerializableFixups
-
Constructor Summary
Constructors Constructor Description Deserializer(CASImpl cas, java.io.DataInput deserIn, boolean isDelta)
Called after header was read and determined that this was a compressed binary
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
closeDataInputs()
private void
createCurrentFs(TypeImpl type, CASImpl view)
private long
decodeDouble(long mants, int exponent)
private int
decodeIntSign(int v)
private void
deserialize(CommonSerDes.Header h)
private java.io.DataInput
getInputStream(SlotKinds.SlotKind kind)
private int[]
getPrevFsRef(TypeImpl type)
lazy initialization of the prevFsRef info FSArray - only need slot 0 non-array - need all the slotsprivate int
getPrevIntValue(SlotKinds.SlotKind kind, FeatureImpl feat)
Common code for feature offset and arrayprivate void
maybeStoreOrDefer(java.util.function.Consumer<TOP> storeAction)
Maybe defers setting features for a Feature Structure if the FS isn't created yet (perhaps because it needs a sofa ref, not yet read)private void
maybeStoreOrDefer_slotFixups(int tgtSeq, java.util.function.Consumer<TOP> r)
FS Ref slots fixupsprivate TOP
readArray(int iHeap, TypeImpl type)
private int
readArrayLength()
private void
readByKind(FeatureImpl feat, TypeImpl type)
If the fs is null, accumulate fixup operations, otherwise directly set thisprivate int
readDiff(java.io.DataInput in, int prev)
private int
readDiff(SlotKinds.SlotKind kind, int prev)
private int
readDiffWithPrevTypeSlot(SlotKinds.SlotKind kind, FeatureImpl feat)
Difference with previously deserialized value of corresponding slot of previous FS for this type.private long
readDouble()
private int
readFloat()
private void
readFsxPart(IntVector fsIndexes)
private void
readIndexedFeatureStructures()
private void
readIntoByteArray(byte[] ba)
private void
readIntoDoubleArray(double[] da)
private void
readIntoLongArray(long[] la)
private void
readIntoShortArray(short[] sa)
private long
readLongOrDouble(SlotKinds.SlotKind kind, long prev)
private java.lang.String
readString()
private long
readVlong(java.io.DataInput dis)
private long
readVlong(java.io.DataInputStream dis)
private int
readVnumber(java.io.DataInputStream dis)
private void
savePrevHeapRef(int typecode, int nbrOfSlots, int offset, int v)
private TOP
seq2fs(int s)
private void
setupReadStream(int slotIndex, int bytesCompr, int bytesOrig)
-
-
-
Field Detail
-
baseCas
private final CASImpl baseCas
-
ivCas
private final CASImpl ivCas
-
bcsd
private final BinaryCasSerDes bcsd
-
csds
private final CommonSerDesSequential csds
-
deserIn
private final java.io.DataInput deserIn
-
dataInputs
private final java.io.DataInputStream[] dataInputs
-
inflaters
private java.util.zip.Inflater[] inflaters
-
currentFs
private TOP currentFs
the FS being deserialized
-
singleFsDefer
private final java.util.List<java.lang.Runnable> singleFsDefer
Deferred actions to set Feature Slots of feature structures. the deferrals needed when deserializing a subtype of AnnotationBase before the sofa is known Also for Sofa creation where some fields are final
-
sofaNum
private int sofaNum
used for deferred creation
-
sofaName
private java.lang.String sofaName
-
sofaRef
private Sofa sofaRef
-
heapStart
private int heapStart
-
heapEnd
private int heapEnd
-
fixupsNeeded
private final java.util.List<java.lang.Runnable> fixupsNeeded
the "fixups" for relative heap refs actions set slot values
-
uimaSerializableFixups
private final java.util.List<java.lang.Runnable> uimaSerializableFixups
-
stringHeapObj
private final StringHeap stringHeapObj
-
isDelta
private final boolean isDelta
-
readCommonString
private java.lang.String[] readCommonString
-
only1CommonString
private boolean only1CommonString
-
arrayLength_dis
private final java.io.DataInputStream arrayLength_dis
-
heapRef_dis
private final java.io.DataInputStream heapRef_dis
-
int_dis
private final java.io.DataInputStream int_dis
-
byte_dis
private final java.io.DataInputStream byte_dis
-
short_dis
private final java.io.DataInputStream short_dis
-
typeCode_dis
private final java.io.DataInputStream typeCode_dis
-
strOffset_dis
private final java.io.DataInputStream strOffset_dis
-
strLength_dis
private final java.io.DataInputStream strLength_dis
-
long_High_dis
private final java.io.DataInputStream long_High_dis
-
long_Low_dis
private final java.io.DataInputStream long_Low_dis
-
float_Mantissa_Sign_dis
private final java.io.DataInputStream float_Mantissa_Sign_dis
-
float_Exponent_dis
private final java.io.DataInputStream float_Exponent_dis
-
double_Mantissa_Sign_dis
private final java.io.DataInputStream double_Mantissa_Sign_dis
-
double_Exponent_dis
private final java.io.DataInputStream double_Exponent_dis
-
fsIndexes_dis
private final java.io.DataInputStream fsIndexes_dis
-
strChars_dis
private final java.io.DataInputStream strChars_dis
-
control_dis
private final java.io.DataInputStream control_dis
-
strSeg_dis
private final java.io.DataInputStream strSeg_dis
-
prevFsRefsByType
private final int[][] prevFsRefsByType
For differencing when reading. Also used for arrays to difference the 0th element. Can't use real fs for heap refs - may be forward refs not yet fixedup Hold prev instance of FS which have FSRef slots for each target typecode, only set if the type - has 1 or more non-array fsref - is a (subtype of) FSArray set for both 0 and non-0 values !! Different from form6 first index: key is type code 2nd index: key is slot-offset number (0-based) Also used for array refs, for the 1st entry in the array - feature slot 0 is used for this when reading (not when writing - could be made more uniform)
-
prevFsRefs
private int[] prevFsRefs
-
prevFsByType
private final TOP[] prevFsByType
Used for differencing, except for HeapRef values which use above
-
prevFs
private TOP prevFs
-
seq2fs
private final Int2ObjHashMap<TOP,TOP> seq2fs
convert between FSs and "sequential" numbers Note: This may be identity map, but may not in the case for V3 where some FSs are GC'd
-
-
Constructor Detail
-
Deserializer
Deserializer(CASImpl cas, java.io.DataInput deserIn, boolean isDelta) throws java.io.IOException
Called after header was read and determined that this was a compressed binary- Parameters:
cas
- CASdeserIn
- input data- Throws:
java.io.IOException
- passthru
-
-
Method Detail
-
deserialize
private void deserialize(CommonSerDes.Header h) throws java.io.IOException
- Throws:
java.io.IOException
-
readArray
private TOP readArray(int iHeap, TypeImpl type) throws java.io.IOException
- Throws:
java.io.IOException
-
readArrayLength
private int readArrayLength() throws java.io.IOException
- Throws:
java.io.IOException
-
readByKind
private void readByKind(FeatureImpl feat, TypeImpl type) throws java.io.IOException
If the fs is null, accumulate fixup operations, otherwise directly set this- Parameters:
fs
- - null or the fs whose slots are to be setfeat
-type
-- Throws:
java.io.IOException
-
readIndexedFeatureStructures
private void readIndexedFeatureStructures() throws java.io.IOException
- Throws:
java.io.IOException
-
maybeStoreOrDefer
private void maybeStoreOrDefer(java.util.function.Consumer<TOP> storeAction)
Maybe defers setting features for a Feature Structure if the FS isn't created yet (perhaps because it needs a sofa ref, not yet read)- Parameters:
fs
- - the Feature Structure or null if not yet createdstoreAction
-
-
maybeStoreOrDefer_slotFixups
private void maybeStoreOrDefer_slotFixups(int tgtSeq, java.util.function.Consumer<TOP> r)
FS Ref slots fixups- Parameters:
tgtSeq
- the int value of the target seq numberr
- is sofa-or-lfs.setFeatureValue-or-setLocalSofaData(TOP ref-d-fs)
-
readFsxPart
private void readFsxPart(IntVector fsIndexes) throws java.io.IOException
- Throws:
java.io.IOException
-
setupReadStream
private void setupReadStream(int slotIndex, int bytesCompr, int bytesOrig) throws java.io.IOException
- Throws:
java.io.IOException
-
closeDataInputs
private void closeDataInputs()
-
getInputStream
private java.io.DataInput getInputStream(SlotKinds.SlotKind kind)
-
readVnumber
private int readVnumber(java.io.DataInputStream dis) throws java.io.IOException
- Throws:
java.io.IOException
-
readVlong
private long readVlong(java.io.DataInputStream dis) throws java.io.IOException
- Throws:
java.io.IOException
-
readIntoByteArray
private void readIntoByteArray(byte[] ba) throws java.io.IOException
- Throws:
java.io.IOException
-
readIntoShortArray
private void readIntoShortArray(short[] sa) throws java.io.IOException
- Throws:
java.io.IOException
-
readIntoDoubleArray
private void readIntoDoubleArray(double[] da) throws java.io.IOException
- Throws:
java.io.IOException
-
readIntoLongArray
private void readIntoLongArray(long[] la) throws java.io.IOException
- Throws:
java.io.IOException
-
readDiffWithPrevTypeSlot
private int readDiffWithPrevTypeSlot(SlotKinds.SlotKind kind, FeatureImpl feat) throws java.io.IOException
Difference with previously deserialized value of corresponding slot of previous FS for this type. Special handling: if the slot is a heap ref, we can't use the prevFs because the value may be a forward reference, not yet deserialized, and therefore unknown. For this case, we preserve the actual deserialized value in a lazyly constructed prevFsRef and use that. For arrays, only the prev 0 value is used (if available - otherwise 0 is used)- Parameters:
kind
- - the slot kind being deserializedfeat
- - the feature (null for arrays)- Returns:
- - the previous value, for differencing
- Throws:
java.io.IOException
-
getPrevIntValue
private int getPrevIntValue(SlotKinds.SlotKind kind, FeatureImpl feat)
Common code for feature offset and array- Parameters:
kind
-feat
- feature or null for array access- Returns:
-
savePrevHeapRef
private void savePrevHeapRef(int typecode, int nbrOfSlots, int offset, int v)
-
readDiff
private int readDiff(SlotKinds.SlotKind kind, int prev) throws java.io.IOException
- Throws:
java.io.IOException
-
readDiff
private int readDiff(java.io.DataInput in, int prev) throws java.io.IOException
- Throws:
java.io.IOException
-
readLongOrDouble
private long readLongOrDouble(SlotKinds.SlotKind kind, long prev) throws java.io.IOException
- Throws:
java.io.IOException
-
readFloat
private int readFloat() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeIntSign
private int decodeIntSign(int v)
-
readDouble
private long readDouble() throws java.io.IOException
- Throws:
java.io.IOException
-
decodeDouble
private long decodeDouble(long mants, int exponent)
-
readVlong
private long readVlong(java.io.DataInput dis) throws java.io.IOException
- Throws:
java.io.IOException
-
readString
private java.lang.String readString() throws java.io.IOException
- Throws:
java.io.IOException
-
getPrevFsRef
private int[] getPrevFsRef(TypeImpl type)
lazy initialization of the prevFsRef info FSArray - only need slot 0 non-array - need all the slots
-
seq2fs
private TOP seq2fs(int s)
-
-