in uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java [1498:1628]
private void extractFsToV2Heaps(TOP fs, boolean isMarkSet, Obj2IntIdentityHashMap<TOP> fs2addr) {
TypeImpl type = fs._getTypeImpl();
// pos is the pos in the new heaps; for delta it needs adjustment if written out
int pos = heap.add(getFsSpaceReq(fs, type), type.getCode());
if (type.isArray()) {
// next slot is the length
final int length = ((CommonArrayFS<?>) fs).size();
heap.heap[pos + arrayLengthFeatOffset] = length;
// next slot are the values
int i = pos + arrayContentOffset;
switch (type.getComponentSlotKind()) {
case Slot_Int:
System.arraycopy(((IntegerArray) fs)._getTheArray(), 0, heap.heap,
pos + arrayContentOffset, length);
break;
case Slot_Float:
for (float v : ((FloatArray) fs)._getTheArray()) {
heap.heap[i++] = CASImpl.float2int(v);
}
break;
case Slot_StrRef:
for (String s : ((StringArray) fs)._getTheArray()) {
int strAddr = stringHeap.addString(s);
// strAddr is the offset in the new str table; for delta, needs adjustment
heap.heap[i++] = (strAddr == 0) ? 0 : nextStringHeapAddrAfterMark + strAddr;
}
break;
case Slot_BooleanRef: {
int baAddr = byteHeap.addBooleanArray(((BooleanArray) fs)._getTheArray());
heap.heap[i] = nextByteHeapAddrAfterMark + baAddr;
byteAuxAddr2fsa.put(nextByteHeapAddrAfterMark + baAddr, fs);
// // hack to find first above-the-mark ref
// if (isMarkSet && baAddr < nextByteHeapAddrAfterMark) {
// nextByteHeapAddrAfterMark = baAddr;
// }
}
break;
case Slot_ByteRef: {
int baAddr = byteHeap.addByteArray(((ByteArray) fs)._getTheArray());
heap.heap[i] = nextByteHeapAddrAfterMark + baAddr;
byteAuxAddr2fsa.put(nextByteHeapAddrAfterMark + baAddr, fs);
// // hack to find first above-the-mark ref
// if (isMarkSet && baAddr < nextByteHeapAddrAfterMark) {
// nextByteHeapAddrAfterMark = baAddr;
// }
}
break;
case Slot_ShortRef: {
int saAddr = shortHeap.addShortArray(((ShortArray) fs)._getTheArray());
heap.heap[i] = nextShortHeapAddrAfterMark + saAddr;
shortAuxAddr2fsa.put(nextShortHeapAddrAfterMark + saAddr, fs);
}
break;
case Slot_LongRef: {
int laAddr = longHeap.addLongArray(((LongArray) fs)._getTheArray());
heap.heap[i] = nextLongHeapAddrAfterMark + laAddr;
longAuxAddr2fsa.put(nextLongHeapAddrAfterMark + laAddr, fs);
break;
}
case Slot_DoubleRef: {
int laAddr = longHeap.addDoubleArray(((DoubleArray) fs)._getTheArray());
heap.heap[i] = nextLongHeapAddrAfterMark + laAddr;
longAuxAddr2fsa.put(nextLongHeapAddrAfterMark + laAddr, fs);
break;
}
case Slot_HeapRef:
for (TOP fsitem : ((FSArray<?>) fs)._getTheArray()) {
heap.heap[i++] = fs2addr.get(fsitem);
}
break;
default:
Misc.internalError();
} // end of switch
} else { // end of is-array
if (fs instanceof UimaSerializable uimaSerializable) {
uimaSerializable._save_to_cas_data();
}
int i = pos + 1;
for (FeatureImpl feat : type.getFeatureImpls()) {
switch (feat.getSlotKind()) {
case Slot_Boolean:
heap.heap[i++] = fs._getBooleanValueNc(feat) ? 1 : 0;
break;
case Slot_Byte:
heap.heap[i++] = fs._getByteValueNc(feat);
break;
case Slot_Short:
heap.heap[i++] = fs._getShortValueNc(feat);
break;
case Slot_Int:
heap.heap[i++] = fs._getIntValueNc(feat);
break;
case Slot_Float:
heap.heap[i++] = CASImpl.float2int(fs._getFloatValueNc(feat));
break;
case Slot_LongRef: {
int lAddr = longHeap.addLong(fs._getLongValueNc(feat));
heap.heap[i++] = nextLongHeapAddrAfterMark + lAddr;
break;
}
case Slot_DoubleRef: {
int lAddr = longHeap.addLong(CASImpl.double2long(fs._getDoubleValueNc(feat)));
heap.heap[i++] = nextLongHeapAddrAfterMark + lAddr;
break;
}
case Slot_StrRef: {
int sAddr = stringHeap.addString(fs._getStringValueNc(feat));
heap.heap[i++] = (sAddr == 0) ? 0 : nextStringHeapAddrAfterMark + sAddr; // is 0 if
// string is
// null
break;
}
case Slot_HeapRef:
heap.heap[i++] = fs2addr.get(fs._getFeatureValueNc(feat));
break;
default:
Misc.internalError();
} // end of switch
} // end of iter over all features
} // end of if-is-not-array
}