Interface DataInputPlus

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  DataInputPlus.DataInputStreamPlus
      Wrapper around an InputStream that provides no buffering but can decode varints
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default long readUnsignedVInt()
      Think hard before opting for an unsigned encoding.
      default int readUnsignedVInt32()
      Read up to a 32-bit integer back.
      default long readVInt()
      Read a 64-bit integer back.
      default int readVInt32()
      Read up to a 32-bit integer back.
      int skipBytes​(int n)
      Always skips the requested number of bytes, unless EOF is reached
      default void skipBytesFully​(int n)  
      • Methods inherited from interface java.io.DataInput

        readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF
    • Method Detail

      • readVInt

        default long readVInt()
                       throws java.io.IOException
        Read a 64-bit integer back. This method assumes it was originally written using DataOutputPlus.writeVInt(long) or similar that zigzag encodes the vint.
        Throws:
        java.io.IOException
      • readVInt32

        default int readVInt32()
                        throws java.io.IOException
        Read up to a 32-bit integer back. This method assumes the integer was originally written using DataOutputPlus.writeVInt32(int) or similar that zigzag encodes the vint.
        Throws:
        VIntCoding.VIntOutOfRangeException - If the vint doesn't fit into a 32-bit integer
        java.io.IOException
      • readUnsignedVInt

        default long readUnsignedVInt()
                               throws java.io.IOException
        Think hard before opting for an unsigned encoding. Is this going to bite someone because some day they might need to pass in a sentinel value using negative numbers? Is the risk worth it to save a few bytes? Signed, not a fan of unsigned values in protocols and formats
        Throws:
        java.io.IOException
      • readUnsignedVInt32

        default int readUnsignedVInt32()
                                throws java.io.IOException
        Read up to a 32-bit integer back. This method assumes the original integer was written using DataOutputPlus.writeUnsignedVInt32(int) or similar that doesn't zigzag encodes the vint.
        Throws:
        VIntCoding.VIntOutOfRangeException - If the vint doesn't fit into a 32-bit integer
        java.io.IOException
      • skipBytes

        int skipBytes​(int n)
               throws java.io.IOException
        Always skips the requested number of bytes, unless EOF is reached
        Specified by:
        skipBytes in interface java.io.DataInput
        Parameters:
        n - number of bytes to skip
        Returns:
        number of bytes skipped
        Throws:
        java.io.IOException
      • skipBytesFully

        default void skipBytesFully​(int n)
                             throws java.io.IOException
        Throws:
        java.io.IOException