Class LongUtils


  • public class LongUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      LongUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int compareHigh​(byte[] a, byte[] b)
      compare according to the dictionary order
      static long fromBDBytes​(byte[] work)
      get the long from the big endian representation bytes
      static byte[] highPart​(long num)
      get the high 48 bit parts of the input data
      static long initWithFirst4Byte​(int v)
      initialize a long value with the given fist 32 bit
      static char lowPart​(long num)
      get the low 16 bit parts of the input data
      static byte[] toBDBytes​(long v)
      to big endian bytes representation
      static long toLong​(byte[] high, char low)
      reconstruct the long data
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LongUtils

        public LongUtils()
    • Method Detail

      • highPart

        public static byte[] highPart​(long num)
        get the high 48 bit parts of the input data
        Parameters:
        num - the long number
        Returns:
        the high 48 bit
      • lowPart

        public static char lowPart​(long num)
        get the low 16 bit parts of the input data
        Parameters:
        num - the long number
        Returns:
        the low 16 bit
      • toLong

        public static long toLong​(byte[] high,
                                  char low)
        reconstruct the long data
        Parameters:
        high - the high 48 bit
        low - the low 16 bit
        Returns:
        the long data
      • toBDBytes

        public static byte[] toBDBytes​(long v)
        to big endian bytes representation
        Parameters:
        v - a long value
        Returns:
        the input long value's big endian byte array representation
      • fromBDBytes

        public static long fromBDBytes​(byte[] work)
        get the long from the big endian representation bytes
        Parameters:
        work - the byte array
        Returns:
        the long data
      • compareHigh

        public static int compareHigh​(byte[] a,
                                      byte[] b)
        compare according to the dictionary order
        Parameters:
        a - a byte array
        b - another byte array
        Returns:
        1 indicates a greater than b,0 indicates equal,-1 indicates a smaller than b
      • initWithFirst4Byte

        public static long initWithFirst4Byte​(int v)
        initialize a long value with the given fist 32 bit
        Parameters:
        v - first 32 bit value
        Returns:
        a long value