// Metadata for the row's table
Table table = rowDef.table();
// Only set if parent row is looked up
int i2hPosition = 0;
IndexToHKey indexToHKey = null;
SDType parentStoreData = null;
IndexRow parentPKIndexRow = null;
// All columns of all segments of the HKey
for(HKeySegment hKeySegment : table.hKey().segments()) {
// Ordinal for this segment
RowDef segmentRowDef = hKeySegment.table().rowDef();
hKeyAppender.append(segmentRowDef.table().getOrdinal());
// Segment's columns
for(HKeyColumn hKeyColumn : hKeySegment.columns()) {
Table hKeyColumnTable = hKeyColumn.column().getTable();
if(hKeyColumnTable != table) {
// HKey column from row of parent table
if (parentStoreData == null) {
// Initialize parent metadata and state
RowDef parentRowDef = rowDef.table().getParentTable().rowDef();
TableIndex parentPkIndex = parentRowDef.getPKIndex();
indexToHKey = parentPkIndex.indexToHKey();
parentStoreData = createStoreData(session, parentPkIndex);
parentPKIndexRow = readIndexRow(session, parentPkIndex, parentStoreData, rowDef, rowData);
i2hPosition = hKeyColumn.positionInHKey();
}
if(indexToHKey.isOrdinal(i2hPosition)) {
assert indexToHKey.getOrdinal(i2hPosition) == segmentRowDef.table().getOrdinal() : hKeyColumn;
++i2hPosition;
}
if(parentPKIndexRow != null) {
parentPKIndexRow.appendFieldTo(indexToHKey.getIndexRowPosition(i2hPosition), hKeyAppender.key());
} else {
// Orphan row
hKeyAppender.appendNull();
}
++i2hPosition;