Package io.airlift.slice
Class InputStreamSliceInput
- java.lang.Object
-
- java.io.InputStream
-
- io.airlift.slice.SliceInput
-
- io.airlift.slice.InputStreamSliceInput
-
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable
public final class InputStreamSliceInput extends SliceInput
-
-
Constructor Summary
Constructors Constructor Description InputStreamSliceInput(InputStream inputStream)InputStreamSliceInput(InputStream inputStream, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns the number of bytes that can be read without blocking.voidclose()longgetRetainedSize()Approximate number of bytes retained by this instance.booleanisReadable()Returnstrueif and only ifavailable()is greater than0.longposition()Returns thepositionof this buffer.intread()intread(byte[] destination, int destinationIndex, int length)booleanreadBoolean()Returns true if the byte at the currentpositionis not0and increases thepositionby1in this buffer.bytereadByte()Gets a byte at the currentpositionand increases thepositionby1in this buffer.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).voidreadBytes(Slice 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).voidreadBytes(OutputStream out, int length)Transfers this buffer's data to the specified stream starting at the currentposition.doublereadDouble()Gets a 64-bit double at the currentpositionand increases thepositionby8in this buffer.floatreadFloat()Gets a 32-bit float at the currentpositionand increases thepositionby4in this buffer.intreadInt()Gets a 32-bit integer at the currentpositionand increases thepositionby4in this buffer.longreadLong()Gets a 64-bit long at the currentpositionand increases thepositionby8in this buffer.shortreadShort()Gets a 16-bit short integer at the currentpositionand increases thepositionby2in this buffer.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).intreadUnsignedByte()Gets an unsigned byte at the currentpositionand increases thepositionby1in this buffer.intreadUnsignedShort()Gets an unsigned 16-bit short integer at the currentpositionand increases thepositionby2in this buffer.voidsetPosition(long position)Sets thepositionof this buffer.longskip(long length)intskipBytes(int n)-
Methods inherited from class io.airlift.slice.SliceInput
mark, markSupported, read, readBytes, readBytes, readBytes, readChar, readFully, readFully, readLine, readUnsignedInt, readUTF, reset
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
InputStreamSliceInput
public InputStreamSliceInput(InputStream inputStream)
-
InputStreamSliceInput
public InputStreamSliceInput(InputStream inputStream, int bufferSize)
-
-
Method Detail
-
position
public long position()
Description copied from class:SliceInputReturns thepositionof this buffer.- Specified by:
positionin classSliceInput
-
setPosition
public void setPosition(long position)
Description copied from class:SliceInputSets thepositionof this buffer.- Specified by:
setPositionin classSliceInput
-
available
public int available()
Description copied from class:SliceInputReturns the number of bytes that can be read without blocking.- Specified by:
availablein classSliceInput
-
isReadable
public boolean isReadable()
Description copied from class:SliceInputReturnstrueif and only ifavailable()is greater than0.- Specified by:
isReadablein classSliceInput
-
skipBytes
public int skipBytes(int n)
- Specified by:
skipBytesin interfaceDataInput- Specified by:
skipBytesin classSliceInput
-
readBoolean
public boolean readBoolean()
Description copied from class:SliceInputReturns true if the byte at the currentpositionis not0and increases thepositionby1in this buffer.- Specified by:
readBooleanin interfaceDataInput- Specified by:
readBooleanin classSliceInput
-
readByte
public byte readByte()
Description copied from class:SliceInputGets a byte at the currentpositionand increases thepositionby1in this buffer.- Specified by:
readBytein interfaceDataInput- Specified by:
readBytein classSliceInput
-
readUnsignedByte
public int readUnsignedByte()
Description copied from class:SliceInputGets an unsigned byte at the currentpositionand increases thepositionby1in this buffer.- Specified by:
readUnsignedBytein interfaceDataInput- Specified by:
readUnsignedBytein classSliceInput
-
readShort
public short readShort()
Description copied from class:SliceInputGets a 16-bit short integer at the currentpositionand increases thepositionby2in this buffer.- Specified by:
readShortin interfaceDataInput- Specified by:
readShortin classSliceInput
-
readUnsignedShort
public int readUnsignedShort()
Description copied from class:SliceInputGets an unsigned 16-bit short integer at the currentpositionand increases thepositionby2in this buffer.- Specified by:
readUnsignedShortin interfaceDataInput- Specified by:
readUnsignedShortin classSliceInput
-
readInt
public int readInt()
Description copied from class:SliceInputGets a 32-bit integer at the currentpositionand increases thepositionby4in this buffer.- Specified by:
readIntin interfaceDataInput- Specified by:
readIntin classSliceInput
-
readLong
public long readLong()
Description copied from class:SliceInputGets a 64-bit long at the currentpositionand increases thepositionby8in this buffer.- Specified by:
readLongin interfaceDataInput- Specified by:
readLongin classSliceInput
-
readFloat
public float readFloat()
Description copied from class:SliceInputGets a 32-bit float at the currentpositionand increases thepositionby4in this buffer.- Specified by:
readFloatin interfaceDataInput- Specified by:
readFloatin classSliceInput
-
readDouble
public double readDouble()
Description copied from class:SliceInputGets a 64-bit double at the currentpositionand increases thepositionby8in this buffer.- Specified by:
readDoublein interfaceDataInput- Specified by:
readDoublein classSliceInput
-
read
public int read()
- Specified by:
readin classSliceInput
-
skip
public long skip(long length)
- Specified by:
skipin classSliceInput
-
read
public int read(byte[] destination, int destinationIndex, int length)- Specified by:
readin classSliceInput
-
readBytes
public void readBytes(byte[] destination, int destinationIndex, int length)Description copied from class:SliceInputTransfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=length).- Specified by:
readBytesin classSliceInputdestinationIndex- the first index of the destinationlength- the number of bytes to transfer
-
readSlice
public Slice readSlice(int length)
Description copied from class:SliceInputReturns a new slice of this buffer's sub-region starting at the currentpositionand increases thepositionby the size of the new slice (=length).- Specified by:
readSlicein classSliceInput- Parameters:
length- the size of the new slice- Returns:
- the newly created slice
-
readBytes
public void readBytes(Slice destination, int destinationIndex, int length)
Description copied from class:SliceInputTransfers this buffer's data to the specified destination starting at the currentpositionand increases thepositionby the number of the transferred bytes (=length).- Specified by:
readBytesin classSliceInputdestinationIndex- the first index of the destinationlength- the number of bytes to transfer
-
readBytes
public void readBytes(OutputStream out, int length) throws IOException
Description copied from class:SliceInputTransfers this buffer's data to the specified stream starting at the currentposition.- Specified by:
readBytesin classSliceInputlength- the number of bytes to transfer- Throws:
IOException- if the specified stream threw an exception during I/O
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classSliceInput
-
getRetainedSize
public long getRetainedSize()
Description copied from class:SliceInputApproximate number of bytes retained by this instance.- Specified by:
getRetainedSizein classSliceInput
-
-