tivrfoa commented on a change in pull request #7487:
URL: https://github.com/apache/pinot/pull/7487#discussion_r719368071



##########
File path: pinot-spi/src/main/java/org/apache/pinot/spi/utils/ByteArray.java
##########
@@ -91,19 +115,55 @@ public int compareTo(@Nonnull ByteArray that) {
    *   <li> +ve integer if first value is larger than the second. </li>
    * </ul>
    *
-   * @param bytes1 First byte[] to compare.
-   * @param bytes2 Second byte[] to compare.
+   * @param left First byte[] to compare.
+   * @param right Second byte[] to compare.
    * @return Result of comparison as stated above.
    */
-  public static int compare(byte[] bytes1, byte[] bytes2) {
-    int len1 = bytes1.length;
-    int len2 = bytes2.length;
+  public static int compare(byte[] left, byte[] right) {
+    return compare(left, 0, left.length, right, 0, right.length);
+  }
+
+  /**
+   * Compares two byte[] values. The comparison performed is on unsigned value 
for each byte.
+   * Returns:
+   * <ul>
+   *   <li> 0 if both values are identical. </li>
+   *   <li> -ve integer if first value is smaller than the second. </li>
+   *   <li> +ve integer if first value is larger than the second. </li>
+   * </ul>
+   *
+   * @param left First byte[] to compare.
+   * @param leftFromIndex inclusive index of first byte to compare in left
+   * @param leftToIndex exclusive index of last byte to compare in left
+   * @param right Second byte[] to compare.
+   * @param rightFromIndex inclusive index of first byte to compare in right
+   * @param rightToIndex exclusive index of last byte to compare in right
+   * @return Result of comparison as stated above.
+   */
+  public static int compare(byte[] left, int leftFromIndex, int leftToIndex,
+      byte[] right, int rightFromIndex, int rightToIndex) {
+    if (COMPARE_UNSIGNED != null) {

Review comment:
       Hi folks!
   
   I was going to ask the question below, but then I understood why 
MethodHandle lookup was used.
   Very nice idea! Multi-release jar is very nice too! =)
   
   ---
   
   Newbie question:<br>
   I need to compile with java version >= 9 to use Arrays.compareUnsigned, but 
if I run with Java 8 I get:<br>
   
   ```
   Error: A JNI error has occurred, please check your installation and try again
   Exception in thread "main" java.lang.UnsupportedClassVersionError: 
JavaVersion has been compiled by a more recent version of the Java Runtime 
(class file version 55.0), this version of the Java Runtime only recognizes 
class file versions up to 52.0
   
   or
   
     bad class file: ./JavaVersion.class
       class file has wrong version 55.0, should be 52.0
       Please remove or make sure it appears in the correct subdirectory of the 
classpath.
   ```
   
   So what's the point to prepare the code for a previous version?<br>
   
   ps: I'm sure I'm missing something. =D




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

Reply via email to