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()); }
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(); }