ancestorHKey = keyCreator.newHKey(index.leafMostTable().hKey());
indexToHKey = ((TableIndex)index).indexToHKey();
}
Key hKey = keyCreator.createKey();
hKey.clear();
for (int i = 0; i < indexToHKey.getLength(); i++) {
if (indexToHKey.isOrdinal(i)) {
hKey.append(indexToHKey.getOrdinal(i));
} else {
int indexField = indexToHKey.getIndexRowPosition(i);
if (index.isSpatial()) {
// A spatial index has a single key column (the z-value), representing the declared spatial key columns.
if (indexField > index.firstSpatialArgument())
indexField -= index.dimensions() - 1;
}
Key keySource = iKey;
if (indexField < 0 || indexField > keySource.getDepth()) {
throw new IllegalStateException(String.format("keySource: %s, indexField: %s",
keySource, indexField));
}
PersistitKey.appendFieldFromKey(hKey, keySource, indexField, index.getIndexName());
}