@Override
public Row next() {
if (!sessions.hasNext()) {
return null;
}
SessionMonitor session = sessions.next();
MonitorStage stage = session.getCurrentStage();
ValuesRow row = new ValuesRow(rowType,
(long)session.getSessionId(),
session.getCallerSessionId() < 0 ? null : (long)session.getCallerSessionId(),
(int)(session.getStartTimeMillis()/1000),
session.getServerType(),
session.getRemoteAddress(),
(stage == null) ? null : stage.name(),
(long)session.getStatementCount(),
session.getCurrentStatement(),
session.getCurrentStatementStartTimeMillis() > 0 ? (int)(session.getCurrentStatementStartTimeMillis() / 1000) : null,
session.getCurrentStatementEndTimeMillis() > 0 ? (int)(session.getCurrentStatementEndTimeMillis()/1000) : null,
session.getRowsProcessed() < 0 ? null : (long)session.getRowsProcessed(),
session.getCurrentStatementPreparedName(),
++rowCounter);
return row;
}