[
https://issues.apache.org/jira/browse/PHOENIX-6587?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17519460#comment-17519460
]
ASF GitHub Bot commented on PHOENIX-6587:
-----------------------------------------
stoty commented on code in PR #1353:
URL: https://github.com/apache/phoenix/pull/1353#discussion_r845921408
##########
phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java:
##########
@@ -595,25 +594,35 @@ public static boolean isSystemTable(byte[] fullTableName)
{
if (QueryConstants.SYSTEM_SCHEMA_NAME.equals(schemaName)) return true;
return false;
}
-
- // Given the splits and the rowKeySchema, find out the keys that
- public static byte[][] processSplits(byte[][] splits,
LinkedHashSet<PColumn> pkColumns, Integer saltBucketNum, boolean
defaultRowKeyOrder) throws SQLException {
- // FIXME: shouldn't this return if splits.length == 0?
- if (splits == null) return null;
- // We do not accept user specified splits if the table is salted and
we specify defaultRowKeyOrder. In this case,
- // throw an exception.
- if (splits.length > 0 && saltBucketNum != null && defaultRowKeyOrder) {
- throw new
SQLExceptionInfo.Builder(SQLExceptionCode.NO_SPLITS_ON_SALTED_TABLE).build().buildException();
- }
- // If the splits are not specified and table is salted, pre-split the
table.
- if (splits.length == 0 && saltBucketNum != null) {
- splits = SaltingUtil.getSalteByteSplitPoints(saltBucketNum);
- }
- byte[][] newSplits = new byte[splits.length][];
+
+ // Given the splits and the rowKeySchema, add the split points based on
saltBucketNum, as well
+ // as the ones passed in the parameter, call processSplit on both, and
return the union.
+ public static byte[][] processSplits(byte[][] splits,
LinkedHashSet<PColumn> pkColumns, Integer saltBucketNum) throws SQLException {
+ if (splits == null) {
+ splits = new byte[0][];
+ }
+
+ TreeSet<byte[]> allSplits = new TreeSet<>(new
Bytes.ByteArrayComparator());
+
+ // Add the salted split points, if any
+ if (saltBucketNum != null) {
+ byte[][] saltSplits =
SaltingUtil.getSaltedByteSplitPoints(saltBucketNum);
+ for (int i=0; i<saltSplits.length; i++) {
+ allSplits.add(processSplit(saltSplits[i], pkColumns));
+ }
+ }
+
+ //Add the specified split points
for (int i=0; i<splits.length; i++) {
- newSplits[i] = processSplit(splits[i], pkColumns);
+ allSplits.add(processSplit(splits[i], pkColumns));
Review Comment:
Added check
> Handle explicit pre-splits for new salted tables and validate splits when
> creating salted tables on existing HBase tables
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: PHOENIX-6587
> URL: https://issues.apache.org/jira/browse/PHOENIX-6587
> Project: Phoenix
> Issue Type: Bug
> Components: core
> Affects Versions: 5.2.0
> Reporter: Istvan Toth
> Assignee: Istvan Toth
> Priority: Minor
>
> Specifying the split points manually on salted tables can break them.
> The easiest thing to do is to disallow it, which ensures that the table is
> created with the default per bucket presplit.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)