Package org.apache.uima.cas.impl
Class BinaryCasSerDes4.Deserializer
java.lang.Object
org.apache.uima.cas.impl.BinaryCasSerDes4.Deserializer
- Enclosing class:
BinaryCasSerDes4
Class instantiated once per deserialization Multiple deserializations in parallel supported,
with multiple instances of this
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classModified Values Modified heap values need fsStartIndexes conversion -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataInputStreamprivate final CASImplprivate final BinaryCasSerDesprivate final DataInputStreamprivate final DataInputStreamprivate final CommonSerDesSequentialprivate TOPthe FS being deserializedprivate final DataInputStream[]private final DataInputprivate final DataInputStreamprivate final DataInputStreamthe "fixups" for relative heap refs actions set slot valuesprivate final DataInputStreamprivate final DataInputStreamprivate final DataInputStreamprivate intprivate final DataInputStreamprivate intprivate Inflater[]private final DataInputStreamprivate final booleanprivate final CASImplprivate final DataInputStreamprivate final DataInputStreamprivate booleanprivate TOPprivate final TOP[]Used for differencing, except for HeapRef values which use aboveprivate int[]private final int[][]For differencing when reading.private String[]private final Int2ObjHashMap<TOP, TOP> 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 final DataInputStreamDeferred actions to set Feature Slots of feature structures.private Stringprivate intused for deferred creationprivate Sofaprivate final DataInputStreamprivate final StringHeapprivate final DataInputStreamprivate final DataInputStreamprivate final DataInputStreamprivate final DataInputStream -
Constructor Summary
ConstructorsConstructorDescriptionDeserializer(CASImpl cas, DataInput deserIn, boolean isDelta) Called after header was read and determined that this was a compressed binary -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidcreateCurrentFs(TypeImpl type, CASImpl view) private longdecodeDouble(long mants, int exponent) private intdecodeIntSign(int v) private voidprivate DataInputprivate int[]getPrevFsRef(TypeImpl type) lazy initialization of the prevFsRef info FSArray - only need slot 0 non-array - need all the slotsprivate intgetPrevIntValue(SlotKinds.SlotKind kind, FeatureImpl feat) Common code for feature offset and arrayprivate voidmaybeStoreOrDefer(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 voidmaybeStoreOrDefer_slotFixups(int tgtSeq, Consumer<TOP> r) FS Ref slots fixupsprivate TOPprivate intprivate voidreadByKind(FeatureImpl feat, TypeImpl type) If the fs is null, accumulate fixup operations, otherwise directly set thisprivate intprivate intreadDiff(SlotKinds.SlotKind kind, int prev) private intreadDiffWithPrevTypeSlot(SlotKinds.SlotKind kind, FeatureImpl feat) Difference with previously deserialized value of corresponding slot of previous FS for this type.private longprivate intprivate voidreadFsxPart(IntVector fsIndexes) private voidprivate voidreadIntoByteArray(byte[] ba) private voidreadIntoDoubleArray(double[] da) private voidreadIntoLongArray(long[] la) private voidreadIntoShortArray(short[] sa) private longreadLongOrDouble(SlotKinds.SlotKind kind, long prev) private Stringprivate longprivate longreadVlong(DataInputStream dis) private intprivate voidsavePrevHeapRef(int typecode, int nbrOfSlots, int offset, int v) private TOPseq2fs(int s) private voidsetupReadStream(int slotIndex, int bytesCompr, int bytesOrig)
-
Field Details
-
baseCas
-
ivCas
-
bcsd
-
csds
-
deserIn
-
dataInputs
-
inflaters
-
currentFs
the FS being deserialized -
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 sofaNumused for deferred creation -
sofaName
-
sofaRef
-
heapStart
private int heapStart -
heapEnd
private int heapEnd -
fixupsNeeded
the "fixups" for relative heap refs actions set slot values -
uimaSerializableFixups
-
stringHeapObj
-
isDelta
private final boolean isDelta -
readCommonString
-
only1CommonString
private boolean only1CommonString -
arrayLength_dis
-
heapRef_dis
-
int_dis
-
byte_dis
-
short_dis
-
typeCode_dis
-
strOffset_dis
-
strLength_dis
-
long_High_dis
-
long_Low_dis
-
float_Mantissa_Sign_dis
-
float_Exponent_dis
-
double_Mantissa_Sign_dis
-
double_Exponent_dis
-
fsIndexes_dis
-
strChars_dis
-
control_dis
-
strSeg_dis
-
prevFsRefsByType
private final int[][] prevFsRefsByTypeFor 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
Used for differencing, except for HeapRef values which use above -
prevFs
-
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 Details
-
Deserializer
Deserializer(CASImpl cas, DataInput deserIn, boolean isDelta) throws IOException Called after header was read and determined that this was a compressed binary- Parameters:
cas- CASdeserIn- input data- Throws:
IOException- passthru
-
-
Method Details
-
deserialize
- Throws:
IOException
-
createCurrentFs
-
readArray
- Throws:
IOException
-
readArrayLength
- Throws:
IOException
-
readByKind
If the fs is null, accumulate fixup operations, otherwise directly set this- Parameters:
feat-type-fs- - null or the fs whose slots are to be set- Throws:
IOException
-
readIndexedFeatureStructures
- Throws:
IOException
-
maybeStoreOrDefer
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:
storeAction-fs- - the Feature Structure or null if not yet created
-
maybeStoreOrDefer_slotFixups
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
- Throws:
IOException
-
setupReadStream
- Throws:
IOException
-
closeDataInputs
private void closeDataInputs() -
getInputStream
-
readVnumber
- Throws:
IOException
-
readVlong
- Throws:
IOException
-
readIntoByteArray
- Throws:
IOException
-
readIntoShortArray
- Throws:
IOException
-
readIntoDoubleArray
- Throws:
IOException
-
readIntoLongArray
- Throws:
IOException
-
readDiffWithPrevTypeSlot
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:
IOException
-
getPrevIntValue
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
- Throws:
IOException
-
readDiff
- Throws:
IOException
-
readLongOrDouble
- Throws:
IOException
-
readFloat
- Throws:
IOException
-
decodeIntSign
private int decodeIntSign(int v) -
readDouble
- Throws:
IOException
-
decodeDouble
private long decodeDouble(long mants, int exponent) -
readVlong
- Throws:
IOException
-
readString
- Throws:
IOException
-
getPrevFsRef
lazy initialization of the prevFsRef info FSArray - only need slot 0 non-array - need all the slots -
seq2fs
-