NihalJain commented on code in PR #168:
URL: 
https://github.com/apache/hbase-operator-tools/pull/168#discussion_r4221613739


##########
hbase-tools/src/main/java/org/apache/hbase/RegionsMerger.java:
##########
@@ -108,23 +105,23 @@ private long sumSizeInFS(Path parentPath) throws 
IOException {
 
   private List<RegionInfo> getOpenRegions(Connection connection, TableName 
table) throws Exception {
     List<RegionInfo> regions = new ArrayList<>();
-    Table metaTbl = connection.getTable(META_TABLE_NAME);
-    String tblName = table.getNameAsString();
-    RowFilter rowFilter =
-      new RowFilter(CompareOperator.EQUAL, new SubstringComparator(tblName + 
","));
     SingleColumnValueFilter colFilter = new 
SingleColumnValueFilter(CATALOG_FAMILY, STATE_QUALIFIER,
       CompareOperator.EQUAL, Bytes.toBytes("OPEN"));
     colFilter.setFilterIfMissing(true);
+    // Scan only this table's rows in meta; a substring match on the table 
name would also pick up
+    // rows of other tables, e.g. "ns:t1" or "abct1" for table "t1".
     Scan scan = new Scan();
-    FilterList filter = new FilterList(FilterList.Operator.MUST_PASS_ALL);
-    filter.addFilter(rowFilter);
-    filter.addFilter(colFilter);
-    scan.setFilter(filter);
-    try (ResultScanner rs = metaTbl.getScanner(scan)) {
+    scan.withStartRow(HBCKMetaTableAccessor.getTableStartRowForMeta(table));
+    scan.withStopRow(HBCKMetaTableAccessor.getTableStopRowForMeta(table));
+    scan.setFilter(colFilter);
+    try (Table metaTbl = connection.getTable(META_TABLE_NAME);
+      ResultScanner rs = metaTbl.getScanner(scan)) {
       Result r;
       while ((r = rs.next()) != null) {
         RegionInfo region = RegionInfo.parseFrom(r.getValue(CATALOG_FAMILY, 
REGIONINFO_QUALIFIER));
-        regions.add(region);
+        if (region.getTable().equals(table)) {

Review Comment:
   nit: region.getTable() should not be null here, but comparing as 
table.equals(region.getTable()) is slightly safer and keeps the non-null 
operand on the left.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to