Class FastByteOperations


  • public final class FastByteOperations
    extends java.lang.Object
    Utility code to do optimized byte-array comparison. This is borrowed and slightly modified from Guava's UnsignedBytes class to be able to compare arrays that start at non-zero offsets. NOTE: This was lifted from Cassandra 2.1 and reduced to the minimum number of methods necessary for the Spark Bulk Writer. Tests in Cassandra, not ported here as more copy/paste didn't seem to be valuable. Also tested via DecoratedKeyTest.
    • Method Detail

      • compareUnsigned

        public static int compareUnsigned​(java.nio.ByteBuffer buffer1,
                                          java.nio.ByteBuffer buffer2)
        Lexicographically compare two byte arrays
        Parameters:
        buffer1 - the first bytebuffer
        buffer2 - the second byteburrer
        Returns:
        standard java comparison return value (-1 for <, 0 for ==, and 1 for >)