}
try {
if (CURSOR_LIFECYCLE_ENABLED) {
CursorLifecycle.checkIdleOrActive(this);
}
Row next = sorter.next();
if(next != null) {
assert next.rowType() == bufferRowType;
// Common case coming out of default Sorters
if(next instanceof ValuesHolderRow) {
ValuesHolderRow valuesRow = (ValuesHolderRow)next;
RowType realRowType = bufferRowType.second();
List<Value> values = valuesRow.values();
next = new ValuesHolderRow(realRowType, values.subList(1, realRowType.nFields() + 1));
} else if(next instanceof CompoundRow) {
next = ((CompoundRow)next).subRow(bufferRowType.second());
} else {
throw new IllegalStateException("Unexpected Row: " + next.getClass());
}
}
return next;
} finally {
if (TAP_NEXT_ENABLED) {