RegionScannerContext checkQuotaAndGetRegionScannerContext(ScanRequest request,
    ScanResponse.Builder builder) throws IOException {
    if (request.hasScannerId()) {
      // The downstream projects such as AsyncHBase in OpenTSDB need this value. See HBASE-18000
      // for more details.
      long scannerId = request.getScannerId();
      builder.setScannerId(scannerId);
      String scannerName = toScannerName(scannerId);
      RegionScannerHolder rsh = getRegionScanner(request);
      OperationQuota quota =
        getRpcQuotaManager().checkScanQuota(rsh.r, request, maxScannerResultSize,
          rsh.getMaxBlockBytesScanned(), rsh.getPrevBlockBytesScannedDifference());
      return new RegionScannerContext(scannerName, rsh, quota);
    }

    HRegion region = getRegion(request.getRegion());
    OperationQuota quota =
      getRpcQuotaManager().checkScanQuota(region, request, maxScannerResultSize, 0L, 0L);
    Pair<String, RegionScannerHolder> pair = newRegionScanner(request, region, builder);
    return new RegionScannerContext(pair.getFirst(), pair.getSecond(), quota);
  }
Scan data in a table.
@param controller the RPC controller
@param request    the scan request
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java