Interface DataInputPlus

All Superinterfaces:
DataInput
All Known Subinterfaces:
FileDataInput, RewindableDataInput, StreamingDataInputPlus
All Known Implementing Classes:
AsyncStreamingInputPlus, ChecksummedDataInput, CompressedChecksummedDataInput, CompressedInputStream, DataInputBuffer, DataInputPlus.DataInputStreamPlus, EncryptedChecksummedDataInput, EncryptedFileSegmentInputStream, FileInputStreamPlus, FileSegmentInputStream, MemoryInputStream, NIODataInputStream, RandomAccessReader, RandomAccessReaderAdapter, RebufferingInputStream, StreamCompressionInputStream, TeeDataInputPlus, TrackedDataInputPlus

public interface DataInputPlus extends DataInput
Extension to DataInput that provides support for reading varints
  • Method Details

    • readVInt

      default long readVInt() throws 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:
      IOException
    • readVInt32

      default int readVInt32() throws 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
      IOException
    • readUnsignedVInt

      default long readUnsignedVInt() throws 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:
      IOException
    • readUnsignedVInt32

      default int readUnsignedVInt32() throws 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
      IOException
    • skipBytes

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

      default void skipBytesFully(int n) throws IOException
      Throws:
      IOException