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
-
Constructor Summary
ConstructorsConstructorDescriptionInputStreamSliceInput(InputStream inputStream) InputStreamSliceInput(InputStream inputStream, int bufferSize) -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bytes that can be read without blocking.voidclose()longApproximate number of bytes retained by this instance.booleanReturnstrueif and only ifavailable()is greater than0.longposition()Returns thepositionof this buffer.intread()intread(byte[] destination, int destinationIndex, int length) booleanReturns 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).voidTransfers 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.doubleGets a 64-bit double at the currentpositionand increases thepositionby8in this buffer.floatGets 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.shortGets a 16-bit short integer at the currentpositionand increases thepositionby2in this buffer.readSlice(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).intGets an unsigned byte at the currentpositionand increases thepositionby1in this buffer.intGets 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, resetMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
InputStreamSliceInput
-
InputStreamSliceInput
-
-
Method Details
-
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
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). The new slice could be either COMPACT or NOT_COMPACT.- Specified by:
readSlicein classSliceInput- Parameters:
length- the size of the new slice- Returns:
- the newly created slice
-
readBytes
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
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
-