Search in sources :

Example 1 with MapRDBTableStats

use of org.apache.drill.exec.store.mapr.db.MapRDBTableStats in project drill by apache.

the class BinaryTableGroupScan method init.

private void init() {
    logger.debug("Getting region locations");
    TableName tableName = TableName.valueOf(hbaseScanSpec.getTableName());
    try (Admin admin = formatPlugin.getConnection().getAdmin();
        RegionLocator locator = formatPlugin.getConnection().getRegionLocator(tableName)) {
        hTableDesc = admin.getTableDescriptor(tableName);
        // Fetch tableStats only once and cache it.
        if (tableStats == null) {
            tableStats = new MapRDBTableStats(getHBaseConf(), hbaseScanSpec.getTableName());
        }
        boolean foundStartRegion = false;
        regionsToScan = new TreeMap<TabletFragmentInfo, String>();
        List<HRegionLocation> regionLocations = locator.getAllRegionLocations();
        for (HRegionLocation regionLocation : regionLocations) {
            HRegionInfo regionInfo = regionLocation.getRegionInfo();
            if (!foundStartRegion && hbaseScanSpec.getStartRow() != null && hbaseScanSpec.getStartRow().length != 0 && !regionInfo.containsRow(hbaseScanSpec.getStartRow())) {
                continue;
            }
            foundStartRegion = true;
            regionsToScan.put(new TabletFragmentInfo(regionInfo), regionLocation.getHostname());
            if (hbaseScanSpec.getStopRow() != null && hbaseScanSpec.getStopRow().length != 0 && regionInfo.containsRow(hbaseScanSpec.getStopRow())) {
                break;
            }
        }
    } catch (Exception e) {
        throw new DrillRuntimeException("Error getting region info for table: " + hbaseScanSpec.getTableName(), e);
    }
    verifyColumns();
}
Also used : MapRDBTableStats(org.apache.drill.exec.store.mapr.db.MapRDBTableStats) RegionLocator(org.apache.hadoop.hbase.client.RegionLocator) Admin(org.apache.hadoop.hbase.client.Admin) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) IOException(java.io.IOException) HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) TableName(org.apache.hadoop.hbase.TableName) HRegionLocation(org.apache.hadoop.hbase.HRegionLocation) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) TabletFragmentInfo(org.apache.drill.exec.store.mapr.db.TabletFragmentInfo)

Aggregations

IOException (java.io.IOException)1 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)1 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)1 MapRDBTableStats (org.apache.drill.exec.store.mapr.db.MapRDBTableStats)1 TabletFragmentInfo (org.apache.drill.exec.store.mapr.db.TabletFragmentInfo)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)1 TableName (org.apache.hadoop.hbase.TableName)1 Admin (org.apache.hadoop.hbase.client.Admin)1 RegionLocator (org.apache.hadoop.hbase.client.RegionLocator)1