joshelser commented on code in PR #1353:
URL: https://github.com/apache/phoenix/pull/1353#discussion_r844175591
##########
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 see that sqlline has some functionality to pass down generic properties,
but we don't have that hooked up through sqlline.py
Can defer this until it bites us, I guess.
--
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]