You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2022/04/06 03:50:36 UTC

[GitHub] [phoenix] stoty commented on a diff in pull request #1353: PHOENIX-6587 Disallow specifying explicit pre-split on salted tables

stoty commented on code in PR #1353:
URL: https://github.com/apache/phoenix/pull/1353#discussion_r843433977


##########
phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java:
##########
@@ -123,4 +130,29 @@ public static void addRegionStartKeyToScanStartAndStopRows(byte[] startKey, byte
             scan.setStopRow(newStopRow);
         }
     }
+
+    public static void checkTableIsSalted(Admin admin, TableName tableName, int buckets) throws IOException, SQLException {
+        // Heuristics to check if and existing HBase table can be a salted Phoenix table
+        // with the specified number of buckets.
+        // May give false negatives.
+        byte[] maxStartKey = new byte[] {0} ;
+        List<RegionInfo> regionInfos =
+                admin.getRegions(tableName);
+        for (RegionInfo regionInfo : regionInfos) {
+            if (Bytes.compareTo(regionInfo.getStartKey(), maxStartKey) > 0) {
+                maxStartKey = regionInfo.getStartKey();
+            }
+        }
+        byte lastRegionStartSaltKey = maxStartKey[0];
+        if (lastRegionStartSaltKey == (byte) (buckets - 1)) {

Review Comment:
   Technically it is possible, but it would be a lot of work as we'd need to start from the grammar to add a force option.
   
   I've handled a few such cases, and in every case it was a user error.
   I have given this some thought, and I cannot imagine such a scenario.
   
   If the user has merged his last regions on his table that otherwise matches the salt bucket count, and wants to create the table, it still wouldn't work correctly, and they are better off fixing their splits first, and re-creating the Phoenix table second.



-- 
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: issues-unsubscribe@phoenix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org