Ejemplo n.º 1
0
 private HBaseSubScanSpec regionInfoToSubScanSpec(HRegionInfo ri) {
   HBaseScanSpec spec = hbaseScanSpec;
   return new HBaseSubScanSpec()
       .setTableName(spec.getTableName())
       .setRegionServer(regionsToScan.get(ri).getHostname())
       .setStartRow(
           (!isNullOrEmpty(spec.getStartRow()) && ri.containsRow(spec.getStartRow()))
               ? spec.getStartRow()
               : ri.getStartKey())
       .setStopRow(
           (!isNullOrEmpty(spec.getStopRow()) && ri.containsRow(spec.getStopRow()))
               ? spec.getStopRow()
               : ri.getEndKey())
       .setSerializedFilter(spec.getSerializedFilter());
 }
Ejemplo n.º 2
0
 @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);
 }
Ejemplo n.º 3
0
  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();
  }