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
--
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]