private void display() throws ExecutorException {
    updateTerminalSize();
    int rowsInBuffer = executor.getRowCount();
    if (rowsInBuffer <= 0 || paused) {
      clearStatusBar();
      drawStatusBar(rowsInBuffer);
      return;
    }

    while (rowsInBuffer > 0) {
      clearStatusBar();
      int step = 10;
      List<String[]> lines = executor.consumeQueryResult(exeContext, 0, step - 1);
      for (String[] line : lines) {
        for (int i = 0; i < line.length; ++i) {
          terminal.writer().write(line[i] == null ? "null" : line[i]);
          terminal.writer().write(i == line.length - 1 ? "\n" : " ");
        }
      }
      terminal.flush();
      clearStatusBar();
      drawStatusBar(rowsInBuffer);

      if (!keepRunning || paused)
        return;

      rowsInBuffer = executor.getRowCount();
    }
  }
A scrolling (logging) view of the query result of a streaming SELECT statement.
samza-sql-shell/src/main/java/org/apache/samza/sql/client/cli/QueryResultLogView.java