Package org.apache.hadoop.hbase.io.util
Class StreamUtils
java.lang.Object
org.apache.hadoop.hbase.io.util.StreamUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic bytereadByte(InputStream in) Read a byte from the given stream using the read method, and throw EOFException if it returns -1, like the implementation inDataInputStream.static longreadLong(InputStream in) readRawVarint32(byte[] input, int offset) Reads a varInt value stored in an array.static intreadRawVarint32(InputStream input) readRawVarint32(ByteBuffer input, int offset) static intreadRawVarint32(ByteBuff input) static shorttoShort(byte hi, byte lo) static voidwriteInt(OutputStream out, int v) static voidwriteLong(OutputStream out, long v) static voidwriteRawVInt32(OutputStream output, int value) static voidwriteShort(OutputStream out, short v)
-
Constructor Details
-
StreamUtils
public StreamUtils()
-
-
Method Details
-
writeRawVInt32
- Throws:
IOException
-
readRawVarint32
- Throws:
IOException
-
readRawVarint32
- Throws:
IOException
-
readRawVarint32
Reads a varInt value stored in an array. Input array where the varInt is available Offset in the input array where varInt is available- Returns:
- A pair of integers in which first value is the actual decoded varInt value and second value as number of bytes taken by this varInt for it's storage in the input array.
- Throws:
IOException- When varint is malformed and not able to be read correctly
-
readRawVarint32
public static Pair<Integer,Integer> readRawVarint32(ByteBuffer input, int offset) throws IOException - Throws:
IOException
-
readByte
Read a byte from the given stream using the read method, and throw EOFException if it returns -1, like the implementation inDataInputStream. This is useful because casting the return value of read method into byte directly will make us lose the ability to check whether there is a byte and its value is -1 or we reach EOF, as casting int -1 to byte also returns -1.- Throws:
IOException
-
toShort
-
writeShort
- Throws:
IOException
-
writeInt
- Throws:
IOException
-
writeLong
- Throws:
IOException
-
readLong
- Throws:
IOException
-