Package herddb.utils
Class ByteArrayCursor
- java.lang.Object
-
- herddb.utils.ByteArrayCursor
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class ByteArrayCursor extends Object implements Closeable
This utility class enables accessing a byte[] while leveragingExtendedDataInputStreamfeatures without performing copies to access data- Author:
- enrico.olivelli
-
-
Constructor Summary
Constructors Constructor Description ByteArrayCursor(byte[] array)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()byte[]getArray()intgetPosition()booleanisEof()intread()byte[]readArray()voidreadArray(int len, byte[] buffer)intreadArrayLen()booleanreadBoolean()bytereadByte()BytesreadBytes()BytesreadBytesNoCopy()doublereadDouble()floatreadFloat()float[]readFloatArray()intreadInt()longreadLong()RawStringreadRawStringNoCopy()intreadVInt()Reads an int stored in variable-length format.intreadVIntNoEOFException()Same asreadVInt()but does not throw EOFException.longreadVLong()Reads a long stored in variable-length format.intreadZInt()longreadZLong()voidskip(int pos)voidskipArray()voidskipBoolean()voidskipDouble()voidskipFloat()voidskipFloatArray()voidskipInt()voidskipLong()static ByteArrayCursorwrap(byte[] array)static ByteArrayCursorwrap(byte[] array, int offset, int length)
-
-
-
Method Detail
-
wrap
public static ByteArrayCursor wrap(byte[] array)
-
wrap
public static ByteArrayCursor wrap(byte[] array, int offset, int length)
-
isEof
public boolean isEof()
-
read
public int read()
-
readByte
public byte readByte() throws IOException- Throws:
IOException
-
readVInt
public int readVInt() throws IOExceptionReads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Returns:
- Throws:
IOException
-
readVIntNoEOFException
public int readVIntNoEOFException() throws IOExceptionSame asreadVInt()but does not throw EOFException. Since throwing exceptions is very expensive for the JVM this operation is preferred if you could hit and EOF- Returns:
- Throws:
IOException- See Also:
isEof()
-
readVLong
public long readVLong() throws IOExceptionReads a long stored in variable-length format. Reads between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.- Returns:
- Throws:
IOException
-
readZInt
public int readZInt() throws IOException- Throws:
IOException
-
readZLong
public long readZLong() throws IOException- Throws:
IOException
-
readArrayLen
public int readArrayLen() throws IOException- Throws:
IOException
-
getPosition
public int getPosition()
-
getArray
public byte[] getArray()
-
readArray
public void readArray(int len, byte[] buffer) throws IOException- Throws:
IOException
-
readInt
public int readInt() throws IOException- Throws:
IOException
-
readFloat
public float readFloat() throws IOException- Throws:
IOException
-
skipFloat
public void skipFloat() throws IOException- Throws:
IOException
-
readLong
public long readLong() throws IOException- Throws:
IOException
-
readDouble
public final double readDouble() throws IOException- Throws:
IOException
-
readBoolean
public final boolean readBoolean() throws IOException- Throws:
IOException
-
readArray
public byte[] readArray() throws IOException- Throws:
IOException
-
readFloatArray
public float[] readFloatArray() throws IOException- Throws:
IOException
-
readBytesNoCopy
public Bytes readBytesNoCopy() throws IOException
- Throws:
IOException
-
readBytes
public Bytes readBytes() throws IOException
- Throws:
IOException
-
readRawStringNoCopy
public RawString readRawStringNoCopy() throws IOException
- Throws:
IOException
-
skipArray
public void skipArray() throws IOException- Throws:
IOException
-
skipFloatArray
public void skipFloatArray() throws IOException- Throws:
IOException
-
skipInt
public void skipInt() throws IOException- Throws:
IOException
-
skipLong
public void skipLong() throws IOException- Throws:
IOException
-
skipDouble
public void skipDouble() throws IOException- Throws:
IOException
-
skipBoolean
public void skipBoolean() throws IOException- Throws:
IOException
-
skip
public void skip(int pos) throws IOException- Throws:
IOException
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-