public boolean containsRow(byte[] row) { return tabletInfoImpl != null ? tabletInfoImpl.containsRow(row) : regionInfo.containsRow(row); }
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"); TableName tableName = TableName.valueOf(hbaseScanSpec.getTableName()); Connection conn = storagePlugin.getConnection(); try (Admin admin = conn.getAdmin(); RegionLocator locator = conn.getRegionLocator(tableName)) { this.hTableDesc = admin.getTableDescriptor(tableName); List<HRegionLocation> regionLocations = locator.getAllRegionLocations(); statsCalculator = new TableStatsCalculator(conn, hbaseScanSpec, storagePlugin.getContext().getConfig(), storagePluginConfig); boolean foundStartRegion = false; regionsToScan = new TreeMap<>(); 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(regionInfo, regionLocation.getServerName()); scanSizeInBytes += statsCalculator.getRegionSizeInBytes(regionInfo.getRegionName()); if (hbaseScanSpec.getStopRow() != null && hbaseScanSpec.getStopRow().length != 0 && regionInfo.containsRow(hbaseScanSpec.getStopRow())) { break; } } } catch (IOException e) { throw new DrillRuntimeException("Error getting region info for table: " + hbaseScanSpec.getTableName(), e); } HBaseUtils.verifyColumns(columns, hTableDesc); }
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; final TreeMap<TabletFragmentInfo, String> 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; } } setRegionsToScan(regionsToScan); } catch (Exception e) { throw new DrillRuntimeException("Error getting region info for table: " + hbaseScanSpec.getTableName(), e); } HBaseUtils.verifyColumns(columns, hTableDesc); }
getConnection(), getTableName(), currentKey); HRegionLocation regionLocation = id < rl.size() ? rl.getRegionLocation(id) : null; if (regionLocation != null && regionLocation.getRegionInfo().containsRow(currentKey)) { regionList.add(regionLocation); } else {
/** * Returns true if the region contains atleast one of the metadata rows we are interested in */ protected static boolean regionContainsMetadataRows(HRegionInfo regionInfo, List<byte[]> metadataRowKeys) { for (byte[] rowKey : metadataRowKeys) { if (regionInfo.containsRow(rowKey)) { return true; } } return false; }
getConnection(), getTableName(), currentKey); HRegionLocation regionLocation = id < rl.size() ? rl.getRegionLocation(id) : null; if (regionLocation != null && regionLocation.getRegionInfo().containsRow(currentKey)) { regionList.add(regionLocation); } else {
public boolean containsRow(byte[] row) { return tabletInfoImpl != null ? tabletInfoImpl.containsRow(row) : regionInfo.containsRow(row); }
/** {@inheritDoc} */ @Override public HRegionLocation getRegionLocation(byte[] row, boolean reload) throws IOException { for(HRegionLocation region : getRegions(reload)) { if (region.getRegionInfo().containsRow(row)) { return region; } } throw new IOException("Region not found for row: " + Bytes.toStringBinary(row)); }
/** {@inheritDoc} */ @Override public HRegionLocation getRegionLocation(byte[] row, boolean reload) throws IOException { for(HRegionLocation region : getRegions(reload)) { if (region.getRegionInfo().containsRow(row)) { return region; } } throw new IOException("Region not found for row: " + Bytes.toStringBinary(row)); }
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"); TableName tableName = TableName.valueOf(hbaseScanSpec.getTableName()); Connection conn = storagePlugin.getConnection(); try (Admin admin = conn.getAdmin(); RegionLocator locator = conn.getRegionLocator(tableName)) { this.hTableDesc = admin.getTableDescriptor(tableName); List<HRegionLocation> regionLocations = locator.getAllRegionLocations(); statsCalculator = new TableStatsCalculator(conn, hbaseScanSpec, storagePlugin.getContext().getConfig(), storagePluginConfig); boolean foundStartRegion = false; regionsToScan = new TreeMap<>(); 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(regionInfo, regionLocation.getServerName()); scanSizeInBytes += statsCalculator.getRegionSizeInBytes(regionInfo.getRegionName()); if (hbaseScanSpec.getStopRow() != null && hbaseScanSpec.getStopRow().length != 0 && regionInfo.containsRow(hbaseScanSpec.getStopRow())) { break; } } } catch (IOException e) { throw new DrillRuntimeException("Error getting region info for table: " + hbaseScanSpec.getTableName(), e); } HBaseUtils.verifyColumns(columns, hTableDesc); }
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; final TreeMap<TabletFragmentInfo, String> 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; } } setRegionsToScan(regionsToScan); } catch (Exception e) { throw new DrillRuntimeException("Error getting region info for table: " + hbaseScanSpec.getTableName(), e); } HBaseUtils.verifyColumns(columns, hTableDesc); }
getConnection(), tableName, currentKey); HRegionLocation regionLocation = id < rl.size() ? rl.getRegionLocation(id) : null; if (regionLocation != null && regionLocation.getRegionInfo().containsRow(currentKey)) { regionList.add(regionLocation); } else {
|| Bytes.compareTo(stopRow, regionInfo.getStartKey()) > 0)) { boolean partial = false; if (!regionInfo.containsRow(startRow)) { startRow = regionInfo.getStartKey(); partial = true; if (!regionInfo.containsRow(stopRow)) { stopRow = new ByteArray(regionInfo.getEndKey()).getNextPrefix(); partial = true;
getConnection(), getTableName(), currentKey); HRegionLocation regionLocation = id < rl.size() ? rl.getRegionLocation(id) : null; if (regionLocation != null && regionLocation.getRegionInfo().containsRow(currentKey)) { regionList.add(regionLocation); } else {
/** * Does checks on split inputs. * @return <code>true</code> if the region is splittable else * <code>false</code> if it is not (e.g. its already closed, etc.). */ public boolean prepare() { if (!this.parent.isSplittable()) return false; // Split key can be null if this region is unsplittable; i.e. has refs. if (this.splitrow == null) return false; HRegionInfo hri = this.parent.getRegionInfo(); parent.prepareToSplit(); // Check splitrow. byte [] startKey = hri.getStartKey(); byte [] endKey = hri.getEndKey(); if (Bytes.equals(startKey, splitrow) || !this.parent.getRegionInfo().containsRow(splitrow)) { LOG.info("Split row is not inside region key range or is equal to " + "startkey: " + Bytes.toStringBinary(this.splitrow)); return false; } long rid = getDaughterRegionIdTimestamp(hri); this.hri_a = new HRegionInfo(hri.getTableName(), startKey, this.splitrow, false, rid); this.hri_b = new HRegionInfo(hri.getTableName(), this.splitrow, endKey, false, rid); return true; }
(splitPoint != null && !r.containsRow(splitPoint))) continue;
/** * Does checks on split inputs. * @return <code>true</code> if the region is splittable else * <code>false</code> if it is not (e.g. its already closed, etc.). */ public boolean prepare() throws IOException { if (!this.parent.isSplittable()) return false; // Split key can be null if this region is unsplittable; i.e. has refs. if (this.splitrow == null) return false; HRegionInfo hri = this.parent.getRegionInfo(); parent.prepareToSplit(); // Check splitrow. byte [] startKey = hri.getStartKey(); byte [] endKey = hri.getEndKey(); if (Bytes.equals(startKey, splitrow) || !this.parent.getRegionInfo().containsRow(splitrow)) { LOG.info("Split row is not inside region key range or is equal to " + "startkey: " + Bytes.toStringBinary(this.splitrow)); return false; } long rid = getDaughterRegionIdTimestamp(hri); this.hri_a = new HRegionInfo(hri.getTable(), startKey, this.splitrow, false, rid); this.hri_b = new HRegionInfo(hri.getTable(), this.splitrow, endKey, false, rid); transition(SplitTransactionPhase.PREPARED); return true; }
if (splitPoint != null && !r.containsRow(splitPoint)) continue;