Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2644#discussion_r211853068
--- Diff: core/src/main/java/org/apache/carbondata/core/util/ByteUtil.java
---
@@ -669,4 +666,44 @@ public static int putBytes(byte[] tgtBytes, int
tgtOffset, byte[] srcBytes, int
return flattenedData;
}
+ /**
+ * perform XOR operation on the value, and convert it to byte array for
sorting
+ */
+ public static byte[] toXorBytes(short val) {
+ val = (short)(val ^ Short.MIN_VALUE);
+ return toBytes(val);
+ }
+
+ public static byte[] toXorBytes(int val) {
+ val = val ^ Integer.MIN_VALUE;
+ return toBytes(val);
+ }
+
+ public static byte[] toXorBytes(long val) {
+ val = val ^ Long.MIN_VALUE;
+ return toBytes(val);
+ }
+
+ public static byte[] toXorBytes(double val) {
+ return toXorBytes(Double.doubleToLongBits(val));
+ }
+
+ /**
+ * convert byte array to the value, perform XOR operation on it to
recover the real value
+ */
+ public static short toXorShort(byte[] bytes, int offset, final int
length) {
+ return (short)(toShort(bytes, offset, length) ^ Short.MIN_VALUE);
+ }
+
+ public static int toXorInt(byte[] bytes, int offset, final int length) {
--- End diff --
please add comment
---