Package org.apache.hadoop.hbase.io.util
Class StreamUtils
java.lang.Object
org.apache.hadoop.hbase.io.util.StreamUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte
readByte
(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 long
readLong
(InputStream in) readRawVarint32
(byte[] input, int offset) Reads a varInt value stored in an array.static int
readRawVarint32
(InputStream input) readRawVarint32
(ByteBuffer input, int offset) static int
readRawVarint32
(ByteBuff input) static short
toShort
(byte hi, byte lo) static void
writeInt
(OutputStream out, int v) static void
writeLong
(OutputStream out, long v) static void
writeRawVInt32
(OutputStream output, int value) static void
writeShort
(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
-