在 HBase 中有没有办法让我获得区域的中间键?

In HBase is there a way for me to get the middle key of a region?

看来我可以像这样得到中间键:

        RegionServerServices rss = null;
        final List<Region> onlineRegions = rss.getOnlineRegions(tableName);

        for (Region region : onlineRegions) {
            final List<Store> stores = region.getStores();
            for (Store store : stores) {
                final long storeSize = store.getSize();
                final byte[] splitPoint = store.getSplitPoint();

            }
        }
    }
}

但是,我无法在客户端获得 HRegionRegionRegionServerService

免责声明:我不确定这种方法的安全性,因为它可能会在 hfile 上设置读锁。我将尝试在快照上使用它,所以我会没事的。

您也不妨:

  • 获取特定列族的存储的中点并且
  • 获取最大商店的中点,当您的区域有多家商店时,这可能会给您更好的近似值

请原谅格式化....

    try (Connection connection = 
                ConnectionFactory.createConnection(hbaseConfig);
                Admin admin = connection.getAdmin();) {
    final List<HRegionInfo> regionInfoList = admin.getTableRegions(tableName);
    HRegionInfo regionInfo = regionInfoList.get(0);
    final HRegion region = HRegion.openHRegion(hbaseConfig,

    FileSystem.get(hbaseConfig),
                                                   new Path("/hbase"),
                                                   regionInfo,
                                                   table.getTableDescriptor(),
                                                   null,
                                                   null,
                                                   null);
     List<Store> stores = region.getStores();
     stores.get(0).getSplitPoint();
    }