Class SizedInts


  • public class SizedInts
    extends java.lang.Object
    Utility class for sizing, writing and reading ints with length stored separately. Used for trie payloads.
    • Constructor Summary

      Constructors 
      Constructor Description
      SizedInts()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int nonZeroSize​(long value)
      Returns the number of bytes we need to store the given position.
      static long read​(java.nio.ByteBuffer src, int startPos, int bytes)  
      static long readUnsigned​(java.nio.ByteBuffer src, int startPos, int bytes)  
      static int sizeAllowingZero​(long value)
      Returns the number of bytes we need to store the given position.
      static void write​(DataOutputPlus dest, long value, int size)  
      • Methods inherited from class java.lang.Object

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

      • SizedInts

        public SizedInts()
    • Method Detail

      • nonZeroSize

        public static int nonZeroSize​(long value)
        Returns the number of bytes we need to store the given position. This method understands 0 to need 1 byte.

        If your use case permits 0 to be encoded in 0 length, use sizeAllowingZero(long) below.

      • sizeAllowingZero

        public static int sizeAllowingZero​(long value)
        Returns the number of bytes we need to store the given position. Returns 0 for 0 argument.
      • read

        public static long read​(java.nio.ByteBuffer src,
                                int startPos,
                                int bytes)
      • readUnsigned

        public static long readUnsigned​(java.nio.ByteBuffer src,
                                        int startPos,
                                        int bytes)
      • write

        public static void write​(DataOutputPlus dest,
                                 long value,
                                 int size)
                          throws java.io.IOException
        Throws:
        java.io.IOException