jatsakthi commented on a change in pull request #14: HBASE-22843 [HBCK2] Fix 
HBCK2 after HBASE-22777 & HBASE-22758
URL: 
https://github.com/apache/hbase-operator-tools/pull/14#discussion_r314435324
 
 

 ##########
 File path: 
hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBCKMetaTableAccessor.java
 ##########
 @@ -0,0 +1,134 @@
+package org.apache.hbase.hbck1;
+
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.client.RegionInfo;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * hbck's local version of the MetaTableAccessor from the hbase repo
+ */
+@InterfaceAudience.Private
+class HBCKMetaTableAccessor {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(HBCKMetaTableAccessor.class);
+  private static final Logger HBCKMETALOG = 
LoggerFactory.getLogger("org.apache.hadoop.hbase.META");
+
+  public static List<RegionInfo> getMergeRegions(Cell[] cells) {
+    if (cells == null) {
+      return null;
+    }
+    List<RegionInfo> regionsToMerge = null;
+    for (Cell cell: cells) {
+      if (!isMergeQualifierPrefix(cell)) {
+        continue;
+      }
+      // Ok. This cell is that of a info:merge* column.
+      RegionInfo ri = RegionInfo.parseFromOrNull(cell.getValueArray(), 
cell.getValueOffset(),
+          cell.getValueLength());
+      if (ri != null) {
+        if (regionsToMerge == null) {
+          regionsToMerge = new ArrayList<>();
+        }
+        regionsToMerge.add(ri);
+      }
+    }
+    return regionsToMerge;
+  }
+
+  private static boolean isMergeQualifierPrefix(Cell cell) {
+    // Check to see if has family and that qualifier starts with the merge 
qualifier 'merge'
+    return CellUtil.matchingFamily(cell, HConstants.CATALOG_FAMILY) &&
+        HBCKPrivateCellUtil.qualifierStartsWith(cell, 
HBCKConstants.MERGE_QUALIFIER_PREFIX);
 
 Review comment:
   Done.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to