class BootstrapProcessor {

  protected boolean computeIsPhaseCompleted(BootstrapEventProcessResult result,
                                            Checkpoint ckpt,
                                            long numRowsReadFromDb,
                                            long maxRowsPerFetch,
                                            long windowScn)
  {
    assert(numRowsReadFromDb <= maxRowsPerFetch);
    boolean isPhaseCompleted = false;
    if (null == result)
    {
      /**
       * There are no rows read from the DB in the resultSet.
       * In this case, it definitely means that "isPhaseCompleted" is true, i.e., bootstrap has finished
       */
      assert(numRowsReadFromDb == 0);
      isPhaseCompleted = true;
    }
    else
    {
      /**
       * Note that 0<= numRowsReadFromDb <= maxRowsPerFetch in this case
       * i.e., numRowsReadFromDb == 0 is possible
       * in the case when all events are filtered out
       */
      if (
          (numRowsReadFromDb < maxRowsPerFetch) &&
          (DbusClientMode.BOOTSTRAP_SNAPSHOT == ckpt.getConsumptionMode())
          )
      {
        /**
         * 1. The total rows processed is less than the max rows per fetch
         * 2. The client is in snapshot mode
         */
        isPhaseCompleted = true;
      }
      else if (
          (numRowsReadFromDb < maxRowsPerFetch) &&
          (DbusClientMode.BOOTSTRAP_CATCHUP == ckpt.getConsumptionMode()) &&
          (ckpt.getBootstrapTargetScn() == windowScn)
          )
      {
        /**
         * 1. If the total rows processed is less than the max rows per fetch
         * 2. The client is in catchup mode
         * 3. We are caught up to targetScn
         */
        isPhaseCompleted = true;
      }

      LOG.info("Terminating batch with result: " + result);

      if (result.isError() || result.isClientBufferLimitExceeded())
      {
        /**
         * Don't write either checkpoint or phaseCompleted when
         * 1. There was an error, or
         * 2. ClientBufferLimit was exceeded
         *
         * Note that even if isPhaseCompleted was set earlier, it is overruled
         */
        isPhaseCompleted = false;
      }
    }
    return isPhaseCompleted;
  }

  public  BootstrapProcessor(BootstrapServerStaticConfig config,
                            DbusEventsStatisticsCollector curStatsCollector);
  protected  BootstrapProcessor();

}