{
Iterator it = createDescendantIterator(session, storeData);
PROPAGATE_CHANGE_TAP.in();
try {
Key hKey = getKey(session, storeData);
RowData rowData = new RowData();
while(it.hasNext()) {
it.next();
expandRowData(session, storeData, rowData);
Table table = ais.getTable(rowData.getRowDefId());
assert (table != null) : rowData.getRowDefId();
int ordinal = table.getOrdinal();
if(tablesRequiringHKeyMaintenance == null || tablesRequiringHKeyMaintenance.get(ordinal)) {
PROPAGATE_REPLACE_TAP.in();
try {
for(RowListener listener : listenerService.getRowListeners()) {
listener.onDeletePre(session, table, hKey, rowData);
}
// Don't call deleteRow as the hKey does not need recomputed.
clear(session, storeData);
table.rowDef().getTableStatus().rowDeleted(session);
for(TableIndex index : table.rowDef().getIndexes()) {
long zValue = -1;
SpatialColumnHandler spatialColumnHandler = null;
if (index.isSpatial()) {
spatialColumnHandler = new SpatialColumnHandler(index);
zValue = spatialColumnHandler.zValue(rowData);
}
deleteIndexRow(session, index, rowData, hKey, indexRowBuffer, spatialColumnHandler, zValue, false);
}
if(!cascadeDelete) {
// Reinsert it, recomputing the hKey and maintaining indexes
RowDef rowDef = getRowDef(ais, rowData.getRowDefId());
writeRow(session, rowDef, rowData, null, tablesRequiringHKeyMaintenance, false);
}
} finally {
PROPAGATE_REPLACE_TAP.out();
}