}
private void concurrentDML(final Session session, TableTransform transform, Key hKey, RowData oldRowData, RowData newRowData) {
final boolean doDelete = (oldRowData != null);
final boolean doWrite = (newRowData != null);
QueryContext context = null;
switch(transform.changeLevel) {
case INDEX:
if(!transform.tableIndexes.isEmpty()) {
WriteIndexRow buffer = new WriteIndexRow (store);
for(TableIndex index : transform.tableIndexes) {
long oldZValue = -1;
long newZValue = -1;
SpatialColumnHandler spatialColumnHandler = null;
if (index.isSpatial()) {
spatialColumnHandler = new SpatialColumnHandler(index);
oldZValue = spatialColumnHandler.zValue(oldRowData);
newZValue = spatialColumnHandler.zValue(newRowData);
}
if(doDelete) {
store.deleteIndexRow(session, index, oldRowData, hKey, buffer, spatialColumnHandler, oldZValue, false);
}
if(doWrite) {
store.writeIndexRow(session, index, newRowData, hKey, buffer, spatialColumnHandler, newZValue, false);
}
}
}
if(!transform.groupIndexes.isEmpty()) {
if(doDelete) {
store.deleteIndexRows(session, transform.rowType.table(), oldRowData, transform.groupIndexes);
}
if(doWrite) {
store.writeIndexRows(session, transform.rowType.table(), newRowData, transform.groupIndexes);
}
}
break;
case TABLE:
if(transform.deleteOperator != null && transform.insertOperator != null) {
Schema schema = transform.rowType.schema();
StoreAdapter adapter = store.createAdapter(session, schema);
context = new SimpleQueryContext(adapter);
QueryBindings bindings = context.createBindings();
if (doDelete) {
Row origOldRow = new RowDataRow(transform.rowType, oldRowData);
bindings.setRow(OperatorAssembler.CREATE_AS_BINDING_POSITION, origOldRow);
try {
runPlan(context, transform.deleteOperator, bindings);
} catch (NoSuchRowException e) {
LOG.debug("row not present: {}", origOldRow);
}
}
if (doWrite) {
Row origOldRow = new RowDataRow(transform.rowType, newRowData);
bindings.setRow(OperatorAssembler.CREATE_AS_BINDING_POSITION, origOldRow);
try {
runPlan(context, transform.insertOperator, bindings);
} catch (NoSuchRowException e) {
LOG.debug("row not present: {}", origOldRow);
}
}
break;
}
case GROUP:
Schema schema = transform.rowType.schema();
StoreAdapter adapter = store.createAdapter(session, schema);
context = new SimpleQueryContext(adapter);
QueryBindings bindings = context.createBindings();
if(doDelete) {
Row origOldRow = new RowDataRow(transform.rowType, oldRowData);
Row newOldRow = transformRow(context, bindings, transform, origOldRow);
try {
adapter.deleteRow(newOldRow, false);