Description
StringPrefixComparator converts the long values back to byte arrays in order to compare them. We should be able to optimize this to compare the longs directly, rather than turning the longs into byte arrays and comparing them byte by byte.
public int compare(long aPrefix, long bPrefix) { // TODO: can done more efficiently byte[] a = Longs.toByteArray(aPrefix); byte[] b = Longs.toByteArray(bPrefix); for (int i = 0; i < 8; i++) { int c = UnsignedBytes.compare(a[i], b[i]); if (c != 0) return c; } return 0; }
Attachments
Issue Links
- is related to
-
SPARK-9483 UTF8String.getPrefix only works in little-endian order
- Resolved
- links to