當前位置: 首頁>>代碼示例>>Java>>正文


Java HRegionInfo.containsRow方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HRegionInfo.containsRow方法的典型用法代碼示例。如果您正苦於以下問題:Java HRegionInfo.containsRow方法的具體用法?Java HRegionInfo.containsRow怎麽用?Java HRegionInfo.containsRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.HRegionInfo的用法示例。


在下文中一共展示了HRegionInfo.containsRow方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
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(), storagePluginConfig);

    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();
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:30,代碼來源:HBaseGroupScan.java

示例2: init

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
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 RuntimeException("Error getting region info for table: " + hbaseScanSpec.getTableName(), e);
  }
  verifyColumns();
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:31,代碼來源:HBaseGroupScan.java

示例3: getRangeDistance

import org.apache.hadoop.hbase.HRegionInfo; //導入方法依賴的package包/類
/**
 * Get the distance between a range's start value and its end value, represented by the percentage
 * of HRegions which a range spans in all the HRegions of the index table.
 * @param range
 * @return
 * @throws IOException-if index table has no region information
 */
public float getRangeDistance(Range range) throws IOException {
  if (range.getStartType() == CompareOp.EQUAL) {
    return -1.0f;
  }

  byte[] startKey = range.getStartValue();
  byte[] endKey = range.getEndValue();

  List<HRegionInfo> infos = indexRegionMaps.get(range.getColumn());
  if (infos == null || infos.size() == 0) {
    throw new IOException("Index table of " + Bytes.toString(range.getColumn())
        + " has no any HRegionInfo!");
  }

  int startRegion = 0;
  int endRegion = infos.size() - 1;

  for (int m = 0; m < infos.size(); m++) {
    HRegionInfo temp = infos.get(m);
    // TODO region start end key may be null
    if (startKey != null && startKey.length != 0) {
      if (temp.containsRow(startKey)) {
        startRegion = m;
      }
    }
    if (endKey != null && endKey.length != 0) {
      if (temp.containsRow(endKey)) {
        endRegion = m;
      }
    }
  }

  // regions between start region and end region (inclusive)
  int dis = (endRegion - startRegion - 1);

  // region percent between startKey and the region's endKey in the whole region
  float startdis = 1.0f;
  if (startKey != null) {
    startdis =
        1 - getByteArrayDistance(infos.get(startRegion).getStartKey(), infos.get(startRegion)
            .getEndKey(), startKey);
  }

  // region percent between endKey and the region's startKey in the whole region
  float enddis = 1.0f;
  if (endKey != null) {
    enddis =
        getByteArrayDistance(infos.get(endRegion).getStartKey(),
          infos.get(endRegion).getEndKey(), endKey);
  }

  return (dis + startdis + enddis) / infos.size();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:61,代碼來源:SimpleIndexChooser.java


注:本文中的org.apache.hadoop.hbase.HRegionInfo.containsRow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。