@Override
 public ScanStats getScanStats() {
   int rowCount =
       (int)
           ((scanSizeInBytes / statsCalculator.getAvgRowSizeInBytes())
               * (hbaseScanSpec.getFilter() != null ? 0.5 : 1));
   // the following calculation is not precise since 'columns' could specify CFs while
   // getColsPerRow() returns the number of qualifier.
   float diskCost =
       scanSizeInBytes
           * ((columns == null || columns.isEmpty())
               ? 1
               : columns.size() / statsCalculator.getColsPerRow());
   return new ScanStats(GroupScanProperty.NO_EXACT_ROW_COUNT, rowCount, 1, diskCost);
 }
  private void init() {
    logger.debug("Getting region locations");
    try {
      HTable table = new HTable(storagePluginConfig.getHBaseConf(), hbaseScanSpec.getTableName());
      this.hTableDesc = table.getTableDescriptor();
      NavigableMap<HRegionInfo, ServerName> regionsMap = table.getRegionLocations();
      statsCalculator =
          new TableStatsCalculator(table, hbaseScanSpec, storagePlugin.getContext().getConfig());

      boolean foundStartRegion = false;
      regionsToScan = new TreeMap<HRegionInfo, ServerName>();
      for (Entry<HRegionInfo, ServerName> mapEntry : regionsMap.entrySet()) {
        HRegionInfo regionInfo = mapEntry.getKey();
        if (!foundStartRegion
            && hbaseScanSpec.getStartRow() != null
            && hbaseScanSpec.getStartRow().length != 0
            && !regionInfo.containsRow(hbaseScanSpec.getStartRow())) {
          continue;
        }
        foundStartRegion = true;
        regionsToScan.put(regionInfo, mapEntry.getValue());
        scanSizeInBytes += statsCalculator.getRegionSizeInBytes(regionInfo.getRegionName());
        if (hbaseScanSpec.getStopRow() != null
            && hbaseScanSpec.getStopRow().length != 0
            && regionInfo.containsRow(hbaseScanSpec.getStopRow())) {
          break;
        }
      }

      table.close();
    } catch (IOException e) {
      throw new DrillRuntimeException(
          "Error getting region info for table: " + hbaseScanSpec.getTableName(), e);
    }
    verifyColumns();
  }