ankitsultana commented on code in PR #12538:
URL: https://github.com/apache/pinot/pull/12538#discussion_r1552662396
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/HashUtils.java:
##########
@@ -44,8 +73,31 @@ public static Object hashPrimaryKey(PrimaryKey primaryKey,
HashFunction hashFunc
return new ByteArray(HashUtils.hashMD5(primaryKey.asBytes()));
case MURMUR3:
return new ByteArray(HashUtils.hashMurmur3(primaryKey.asBytes()));
+ case UUID:
+ return new ByteArray(HashUtils.hashUUID(primaryKey.getValues()));
default:
throw new IllegalArgumentException(String.format("Unrecognized hash
function %s", hashFunction));
}
}
+
+ /**
+ * Concatenates the string representation of all values into a single byte
array. Each element is prepended with its
+ * 4-byte length to ensure no collisions can happen. (sacrifice space
efficiency for correctness)
+ */
+ private static byte[] concatenate(Object[] values) {
+ byte[][] allValueBytes = new byte[values.length][];
+ int totalLen = 0;
+ for (int j = 0; j < allValueBytes.length; j++) {
+ allValueBytes[j] = values[j] == null ?
"null".getBytes(StandardCharsets.UTF_8)
Review Comment:
Is the default behavior to throw when there's a real null? I don't think we
handle null in `PrimaryKey`:
https://github.com/apache/pinot/blob/master/pinot-spi/src/main/java/org/apache/pinot/spi/data/readers/PrimaryKey.java#L43
We can also throw here to be consistent with other functions.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]