@Override
  public Result next() throws IOException {
    Result result = null;
    while (true) {
      if (currentRegionScanner == null) {
        currentRegion++;
        if (currentRegion >= regions.size()) {
          return null;
        }

        RegionInfo hri = regions.get(currentRegion);
        currentRegionScanner =
          new ClientSideRegionScanner(conf, fs, restoreDir, htd, hri, scan, scanMetrics);
        if (this.scanMetrics != null) {
          this.scanMetrics.countOfRegions.incrementAndGet();
        }
      }

      try {
        result = currentRegionScanner.next();
        if (result != null) {
          if (scan.getLimit() > 0 && ++this.numOfCompleteRows > scan.getLimit()) {
            result = null;
          }
          return result;
        }
      } finally {
        if (result == null) {
          currentRegionScanner.close();
          currentRegionScanner = null;
        }
      }
    }
  }
Creates a TableSnapshotScanner.
@param conf                    the configuration
@param rootDir                 root directory for HBase.
@param restoreDir              a temporary directory to copy the snapshot files into. Current
                               user should have write permissions to this directory, and this
                               should not be a subdirectory of rootdir. The scanner deletes the
                               contents of the directory once the scanner is closed.
@param snapshotName            the name of the snapshot to read from
@param scan                    a Scan representing scan parameters
@param snapshotAlreadyRestored true to indicate that snapshot has been restored.
@throws IOException in case of error
hbase-server/src/main/java/org/apache/hadoop/hbase/client/TableSnapshotScanner.java