Package io.airlift.slice
Class SliceInput
java.lang.Object
java.io.InputStream
io.airlift.slice.SliceInput
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable
- Direct Known Subclasses:
FixedLengthSliceInput,InputStreamSliceInput
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intReturns the number of bytes that can be read without blocking.voidclose()abstract longApproximate number of bytes retained by this instance.abstract booleanReturnstrueif and only ifavailable()is greater than0.final voidmark(int readLimit) final booleanabstract longposition()Returns thepositionof this buffer.abstract intread()final intread(byte[] destination) abstract intread(byte[] destination, int destinationIndex, int length) abstract booleanReturns true if the byte at the currentpositionis not0and increases thepositionby1in this buffer.abstract bytereadByte()Gets a byte at the currentpositionand increases thepositionby1in this buffer.final voidreadBytes(byte[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=dst.length).abstract voidreadBytes(byte[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=length).final voidTransfers this buffer's data to the specified destination starting at the currentpositionuntil the destination becomes non-writable, and increases thepositionby the number of the transferred bytes.final voidTransfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=length).abstract voidTransfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=length).abstract voidreadBytes(OutputStream out, int length) Transfers this buffer's data to the specified stream starting at the currentposition.final charreadChar()abstract doubleGets a 64-bit double at the currentpositionand increases thepositionby8in this buffer.final voidreadDoubles(double[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred doubles (=dst.length).abstract voidreadDoubles(double[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred doubles (=length).abstract floatGets a 32-bit float at the currentpositionand increases thepositionby4in this buffer.final voidreadFloats(float[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred floats (=dst.length).abstract voidreadFloats(float[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred floats (=length).final voidreadFully(byte[] destination) final voidreadFully(byte[] destination, int offset, int length) abstract intreadInt()Gets a 32-bit integer at the currentpositionand increases thepositionby4in this buffer.final voidreadInts(int[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred ints (=dst.length).abstract voidreadInts(int[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred ints (=length).final StringreadLine()abstract longreadLong()Gets a 64-bit long at the currentpositionand increases thepositionby8in this buffer.final voidreadLongs(long[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred longs (=dst.length).abstract voidreadLongs(long[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred longs (=length).abstract shortGets a 16-bit short integer at the currentpositionand increases thepositionby2in this buffer.final voidreadShorts(short[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred shorts (=dst.length).abstract voidreadShorts(short[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred shorts (=length).abstract SlicereadSlice(int length) Returns a new slice of this buffer's sub-region starting at the currentpositionand increases thepositionby the size of the new slice (=length).abstract intGets an unsigned byte at the currentpositionand increases thepositionby1in this buffer.final longGets an unsigned 32-bit integer at the currentpositionand increases thepositionby4in this buffer.abstract intGets an unsigned 16-bit short integer at the currentpositionand increases thepositionby2in this buffer.final StringreadUTF()final voidreset()abstract voidsetPosition(long position) Sets thepositionof this buffer.abstract longskip(long length) abstract intskipBytes(int length) Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
SliceInput
public SliceInput()
-
-
Method Details
-
position
public abstract long position()Returns thepositionof this buffer. -
setPosition
public abstract void setPosition(long position) Sets thepositionof this buffer.- Throws:
IndexOutOfBoundsException- if the specifiedpositionis less than0or greater thanthis.writerIndex
-
isReadable
public abstract boolean isReadable()Returnstrueif and only ifavailable()is greater than0. -
available
public abstract int available()Returns the number of bytes that can be read without blocking.- Overrides:
availablein classInputStream
-
read
public abstract int read()- Specified by:
readin classInputStream
-
readBoolean
public abstract boolean readBoolean()Returns true if the byte at the currentpositionis not0and increases thepositionby1in this buffer.- Specified by:
readBooleanin interfaceDataInput- Throws:
IndexOutOfBoundsException- ifthis.available()is less than1
-
readByte
public abstract byte readByte()Gets a byte at the currentpositionand increases thepositionby1in this buffer.- Specified by:
readBytein interfaceDataInput- Throws:
IndexOutOfBoundsException- ifthis.available()is less than1
-
readUnsignedByte
public abstract int readUnsignedByte()Gets an unsigned byte at the currentpositionand increases thepositionby1in this buffer.- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IndexOutOfBoundsException- ifthis.available()is less than1
-
readShort
public abstract short readShort()Gets a 16-bit short integer at the currentpositionand increases thepositionby2in this buffer.- Specified by:
readShortin interfaceDataInput- Throws:
IndexOutOfBoundsException- ifthis.available()is less than2
-
readUnsignedShort
public abstract int readUnsignedShort()Gets an unsigned 16-bit short integer at the currentpositionand increases thepositionby2in this buffer.- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IndexOutOfBoundsException- ifthis.available()is less than2
-
readInt
public abstract int readInt()Gets a 32-bit integer at the currentpositionand increases thepositionby4in this buffer.- Specified by:
readIntin interfaceDataInput- Throws:
IndexOutOfBoundsException- ifthis.available()is less than4
-
readUnsignedInt
public final long readUnsignedInt()Gets an unsigned 32-bit integer at the currentpositionand increases thepositionby4in this buffer.- Throws:
IndexOutOfBoundsException- ifthis.available()is less than4
-
readLong
public abstract long readLong()Gets a 64-bit long at the currentpositionand increases thepositionby8in this buffer.- Specified by:
readLongin interfaceDataInput- Throws:
IndexOutOfBoundsException- ifthis.available()is less than8
-
readFloat
public abstract float readFloat()Gets a 32-bit float at the currentpositionand increases thepositionby4in this buffer.- Specified by:
readFloatin interfaceDataInput- Throws:
IndexOutOfBoundsException- ifthis.available()is less than4
-
readDouble
public abstract double readDouble()Gets a 64-bit double at the currentpositionand increases thepositionby8in this buffer.- Specified by:
readDoublein interfaceDataInput- Throws:
IndexOutOfBoundsException- ifthis.available()is less than8
-
readSlice
Returns a new slice of this buffer's sub-region starting at the currentpositionand increases thepositionby the size of the new slice (=length). The new slice could be either COMPACT or NOT_COMPACT.- Parameters:
length- the size of the new slice- Returns:
- the newly created slice
- Throws:
IndexOutOfBoundsException- iflengthis greater thanthis.available()
-
readFully
public final void readFully(byte[] destination) -
read
public final int read(byte[] destination) - Overrides:
readin classInputStream
-
read
public abstract int read(byte[] destination, int destinationIndex, int length) - Overrides:
readin classInputStream
-
readBytes
public final void readBytes(byte[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=dst.length).- Throws:
IndexOutOfBoundsException- ifdst.lengthis greater thanthis.available()
-
readFully
public final void readFully(byte[] destination, int offset, int length) -
readBytes
public abstract void readBytes(byte[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=length).- Parameters:
destinationIndex- the first index of the destinationlength- the number of bytes to transfer- Throws:
IndexOutOfBoundsException- if the specifieddestinationIndexis less than0, iflengthis greater thanthis.available(), or ifdestinationIndex + lengthis greater thandestination.length
-
readShorts
public final void readShorts(short[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred shorts (=dst.length).- Throws:
IndexOutOfBoundsException- ifdst.lengthis greater thanthis.available()
-
readShorts
public abstract void readShorts(short[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred shorts (=length).- Parameters:
destinationIndex- the first index of the destinationlength- the number of shorts to transfer- Throws:
IndexOutOfBoundsException- if the specifieddestinationIndexis less than0, iflengthis greater thanthis.available(), or ifdestinationIndex + lengthis greater thandestination.length
-
readInts
public final void readInts(int[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred ints (=dst.length).- Throws:
IndexOutOfBoundsException- ifdst.lengthis greater thanthis.available()
-
readInts
public abstract void readInts(int[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred ints (=length).- Parameters:
destinationIndex- the first index of the destinationlength- the number of ints to transfer- Throws:
IndexOutOfBoundsException- if the specifieddestinationIndexis less than0, iflengthis greater thanthis.available(), or ifdestinationIndex + lengthis greater thandestination.length
-
readLongs
public final void readLongs(long[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred longs (=dst.length).- Throws:
IndexOutOfBoundsException- ifdst.lengthis greater thanthis.available()
-
readLongs
public abstract void readLongs(long[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred longs (=length).- Parameters:
destinationIndex- the first index of the destinationlength- the number of longs to transfer- Throws:
IndexOutOfBoundsException- if the specifieddestinationIndexis less than0, iflengthis greater thanthis.available(), or ifdestinationIndex + lengthis greater thandestination.length
-
readFloats
public final void readFloats(float[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred floats (=dst.length).- Throws:
IndexOutOfBoundsException- ifdst.lengthis greater thanthis.available()
-
readFloats
public abstract void readFloats(float[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred floats (=length).- Parameters:
destinationIndex- the first index of the destinationlength- the number of floats to transfer- Throws:
IndexOutOfBoundsException- if the specifieddestinationIndexis less than0, iflengthis greater thanthis.available(), or ifdestinationIndex + lengthis greater thandestination.length
-
readDoubles
public final void readDoubles(double[] destination) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred doubles (=dst.length).- Throws:
IndexOutOfBoundsException- ifdst.lengthis greater thanthis.available()
-
readDoubles
public abstract void readDoubles(double[] destination, int destinationIndex, int length) Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred doubles (=length).- Parameters:
destinationIndex- the first index of the destinationlength- the number of doubles to transfer- Throws:
IndexOutOfBoundsException- if the specifieddestinationIndexis less than0, iflengthis greater thanthis.available(), or ifdestinationIndex + lengthis greater thandestination.length
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentpositionuntil the destination becomes non-writable, and increases thepositionby the number of the transferred bytes. This method is basically same withreadBytes(Slice, int, int), except that this method increases thewriterIndexof the destination by the number of the transferred bytes whilereadBytes(Slice, int, int)does not.- Throws:
IndexOutOfBoundsException- ifdestination.writableBytesis greater thanthis.available()
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=length). This method is basically same withreadBytes(Slice, int, int), except that this method increases thewriterIndexof the destination by the number of the transferred bytes (=length) whilereadBytes(Slice, int, int)does not.- Throws:
IndexOutOfBoundsException- iflengthis greater thanthis.available()or iflengthis greater thandestination.writableBytes
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=length).- Parameters:
destinationIndex- the first index of the destinationlength- the number of bytes to transfer- Throws:
IndexOutOfBoundsException- if the specifieddestinationIndexis less than0, iflengthis greater thanthis.available(), or ifdestinationIndex + lengthis greater thandestination.capacity
-
readBytes
Transfers this buffer's data to the specified stream starting at the currentposition.- Parameters:
length- the number of bytes to transfer- Throws:
IndexOutOfBoundsException- iflengthis greater thanthis.available()IOException- if the specified stream threw an exception during I/O
-
skip
public abstract long skip(long length) - Overrides:
skipin classInputStream
-
skipBytes
public abstract int skipBytes(int length) -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream
-
getRetainedSize
public abstract long getRetainedSize()Approximate number of bytes retained by this instance. -
mark
public final void mark(int readLimit) - Overrides:
markin classInputStream
-
reset
public final void reset()- Overrides:
resetin classInputStream
-
markSupported
public final boolean markSupported()- Overrides:
markSupportedin classInputStream
-
readChar
public final char readChar() -
readLine
-
readUTF
-