diff options
author | Takeshi YAMAMURO <linguin.m.s@gmail.com> | 2015-10-01 21:33:27 -0400 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2015-10-01 21:33:27 -0400 |
commit | 2272962eb087ffedaee12c761506e33e45bd0239 (patch) | |
tree | 879167d8dc582986f685ec2338d7696e3317319d /core/src | |
parent | 01cd688f5245cbb752863100b399b525b31c3510 (diff) | |
download | spark-2272962eb087ffedaee12c761506e33e45bd0239.tar.gz spark-2272962eb087ffedaee12c761506e33e45bd0239.tar.bz2 spark-2272962eb087ffedaee12c761506e33e45bd0239.zip |
[SPARK-9867] [SQL] Move utilities for binary data into ByteArray
The utilities such as Substring#substringBinarySQL and BinaryPrefixComparator#computePrefix for binary data are put together in ByteArray for easy-to-read.
Author: Takeshi YAMAMURO <linguin.m.s@gmail.com>
Closes #8122 from maropu/CleanUpForBinaryType.
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/java/org/apache/spark/util/collection/unsafe/sort/PrefixComparators.java | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/PrefixComparators.java b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/PrefixComparators.java index 71b76d5ddf..d2bf297c6c 100644 --- a/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/PrefixComparators.java +++ b/core/src/main/java/org/apache/spark/util/collection/unsafe/sort/PrefixComparators.java @@ -21,6 +21,7 @@ import com.google.common.primitives.UnsignedLongs; import org.apache.spark.annotation.Private; import org.apache.spark.unsafe.Platform; +import org.apache.spark.unsafe.types.ByteArray; import org.apache.spark.unsafe.types.UTF8String; import org.apache.spark.util.Utils; @@ -62,21 +63,7 @@ public class PrefixComparators { } public static long computePrefix(byte[] bytes) { - if (bytes == null) { - return 0L; - } else { - /** - * TODO: If a wrapper for BinaryType is created (SPARK-8786), - * these codes below will be in the wrapper class. - */ - final int minLen = Math.min(bytes.length, 8); - long p = 0; - for (int i = 0; i < minLen; ++i) { - p |= (128L + Platform.getByte(bytes, Platform.BYTE_ARRAY_OFFSET + i)) - << (56 - 8 * i); - } - return p; - } + return ByteArray.getPrefix(bytes); } } |