Module org.elasticsearch.server
Class ByteBufferStreamInput
java.lang.Object
java.io.InputStream
org.elasticsearch.common.io.stream.StreamInput
org.elasticsearch.common.io.stream.ByteBufferStreamInput
- All Implemented Interfaces:
Closeable
,AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
Closes the stream to further operations.protected void
ensureCanReadBytes
(int length) This method throws anEOFException
if the given number of bytes can not be read from the stream.void
mark
(int readlimit) boolean
int
read()
int
read
(byte[] b, int off, int len) byte
readByte()
Reads and returns a single byte.void
readBytes
(byte[] b, int offset, int len) Reads a specified number of bytes into an array at the specified offset.int
readInt()
Reads four bytes and returns an int.long
readLong()
Reads eight bytes and returns a long.short
Reads the same bytes returned byStreamInput.readReleasableBytesReference()
but does not retain a reference to these bytes.int
readVInt()
Reads an int stored in variable-length format.static int
readVInt
(ByteBuffer buffer) Read a vInt encoded in the format written byStreamOutput.writeVInt(int)
from aByteBuffer
.long
Reads a long stored in variable-length format.static long
readVLong
(ByteBuffer buffer) Read a vLong encoded in the format written byStreamOutput.writeVLong(long)
from aByteBuffer
.void
reset()
long
skip
(long n) Methods inherited from class org.elasticsearch.common.io.stream.StreamInput
doReadString, getTransportVersion, namedWriteableRegistry, readAllToReleasableBytesReference, readArray, readArraySize, readBigInteger, readBoolean, readByteArray, readBytesRef, readBytesRef, readBytesReference, readBytesReference, readCollection, readCollectionAsImmutableList, readCollectionAsImmutableSet, readCollectionAsList, readCollectionAsSet, readDouble, readDoubleArray, readEnum, readEnumSet, readException, readFloat, readFloatArray, readFully, readGenericMap, readGenericValue, readGeoPoint, readImmutableMap, readImmutableMap, readImmutableOpenMap, readInstant, readIntArray, readLongArray, readMap, readMap, readMapOfLists, readMapValues, readNamedWriteable, readNamedWriteable, readNamedWriteableCollectionAsList, readOptional, readOptionalArray, readOptionalBoolean, readOptionalByteArray, readOptionalBytesReference, readOptionalCollectionAsList, readOptionalDouble, readOptionalEnum, readOptionalFloat, readOptionalFloatArray, readOptionalInstant, readOptionalInt, readOptionalLong, readOptionalNamedWriteable, readOptionalSecureString, readOptionalString, readOptionalStringArray, readOptionalStringCollectionAsList, readOptionalText, readOptionalTimeValue, readOptionalVInt, readOptionalVLong, readOptionalWriteable, readOptionalZoneId, readOrderedMap, readReleasableBytesReference, readSecureString, readStringArray, readStringCollectionAsImmutableList, readStringCollectionAsList, readText, readTimeValue, readVIntArray, readVIntSlow, readVLongArray, readVLongSlow, readZLong, readZoneId, setTransportVersion, supportReadAllToReleasableBytesReference, throwEOF, throwOnBrokenVInt, throwOnBrokenVLong, throwOnNullRead, tryReadStringFromBytes, wrap, wrap
Methods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
ByteBufferStreamInput
-
-
Method Details
-
readVInt
Read a vInt encoded in the format written byStreamOutput.writeVInt(int)
from aByteBuffer
. The buffer is assumed to contain enough bytes to fully read the value and its position is moved by this method.- Parameters:
buffer
- buffer to read from- Returns:
- value read from the buffer
- Throws:
IOException
- if buffer does not contain a valid vInt starting from the current position
-
readVLong
Read a vLong encoded in the format written byStreamOutput.writeVLong(long)
from aByteBuffer
. The buffer is assumed to contain enough bytes to fully read the value and its position is moved by this method.- Parameters:
buffer
- buffer to read from- Returns:
- value read from the buffer
- Throws:
IOException
- if buffer does not contain a valid vLong starting from the current position
-
readString
- Overrides:
readString
in classStreamInput
- Throws:
IOException
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
readByte
Description copied from class:StreamInput
Reads and returns a single byte.- Specified by:
readByte
in classStreamInput
- Throws:
IOException
-
read
- Specified by:
read
in classStreamInput
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
readBytes
Description copied from class:StreamInput
Reads a specified number of bytes into an array at the specified offset.- Specified by:
readBytes
in classStreamInput
- Parameters:
b
- the array to read bytes intooffset
- the offset in the array to start storing byteslen
- the number of bytes to read- Throws:
IOException
-
readShort
- Overrides:
readShort
in classStreamInput
- Throws:
IOException
-
readInt
Description copied from class:StreamInput
Reads four bytes and returns an int.- Overrides:
readInt
in classStreamInput
- Throws:
IOException
-
readVInt
Description copied from class:StreamInput
Reads an int stored in variable-length format. Reads between one and five bytes. Smaller values take fewer bytes. Negative numbers will always use all 5 bytes and are therefore better serialized usingStreamInput.readInt()
- Overrides:
readVInt
in classStreamInput
- Throws:
IOException
-
readLong
Description copied from class:StreamInput
Reads eight bytes and returns a long.- Overrides:
readLong
in classStreamInput
- Throws:
IOException
-
readVLong
Description copied from class:StreamInput
Reads a long stored in variable-length format. Reads between one and ten bytes. Smaller values take fewer bytes. Negative numbers are encoded in ten bytes so preferStreamInput.readLong()
orStreamInput.readZLong()
for negative numbers.- Overrides:
readVLong
in classStreamInput
- Throws:
IOException
-
reset
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
available
- Specified by:
available
in classStreamInput
- Throws:
IOException
-
ensureCanReadBytes
Description copied from class:StreamInput
This method throws anEOFException
if the given number of bytes can not be read from the stream. This method might be a no-op depending on the underlying implementation if the information of the remaining bytes is not present.- Specified by:
ensureCanReadBytes
in classStreamInput
- Throws:
EOFException
-
readSlicedBytesReference
Description copied from class:StreamInput
Reads the same bytes returned byStreamInput.readReleasableBytesReference()
but does not retain a reference to these bytes. The returnedBytesReference
thus only contains valid content as long as the underlying buffer has not been released. This method should be preferred overStreamInput.readReleasableBytesReference()
when the returned reference is known to not be used past the lifetime of the underlying buffer as it requires fewer allocations and does not require a potentially costly reference count change.- Overrides:
readSlicedBytesReference
in classStreamInput
- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
mark
in classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
close
Description copied from class:StreamInput
Closes the stream to further operations.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classStreamInput
- Throws:
IOException
-