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 TypeMethodDescriptionintvoidclose()Closes the stream to further operations.protected voidensureCanReadBytes(int length) This method throws anEOFExceptionif the given number of bytes can not be read from the stream.voidmark(int readlimit) booleanintread()intread(byte[] b, int off, int len) bytereadByte()Reads and returns a single byte.voidreadBytes(byte[] b, int offset, int len) Reads a specified number of bytes into an array at the specified offset.intreadInt()Reads four bytes and returns an int.longreadLong()Reads eight bytes and returns a long.shortReads the same bytes returned byStreamInput.readReleasableBytesReference()but does not retain a reference to these bytes.intreadVInt()Reads an int stored in variable-length format.static intreadVInt(ByteBuffer buffer) Read a vInt encoded in the format written byStreamOutput.writeVInt(int)from aByteBuffer.longReads a long stored in variable-length format.static longreadVLong(ByteBuffer buffer) Read a vLong encoded in the format written byStreamOutput.writeVLong(long)from aByteBuffer.voidreset()longskip(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, wrapMethods 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:
readStringin classStreamInput- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
readByte
Description copied from class:StreamInputReads and returns a single byte.- Specified by:
readBytein classStreamInput- Throws:
IOException
-
read
- Specified by:
readin classStreamInput- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
readBytes
Description copied from class:StreamInputReads a specified number of bytes into an array at the specified offset.- Specified by:
readBytesin 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:
readShortin classStreamInput- Throws:
IOException
-
readInt
Description copied from class:StreamInputReads four bytes and returns an int.- Overrides:
readIntin classStreamInput- Throws:
IOException
-
readVInt
Description copied from class:StreamInputReads 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:
readVIntin classStreamInput- Throws:
IOException
-
readLong
Description copied from class:StreamInputReads eight bytes and returns a long.- Overrides:
readLongin classStreamInput- Throws:
IOException
-
readVLong
Description copied from class:StreamInputReads 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:
readVLongin classStreamInput- Throws:
IOException
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
available
- Specified by:
availablein classStreamInput- Throws:
IOException
-
ensureCanReadBytes
Description copied from class:StreamInputThis method throws anEOFExceptionif 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:
ensureCanReadBytesin classStreamInput- Throws:
EOFException
-
readSlicedBytesReference
Description copied from class:StreamInputReads the same bytes returned byStreamInput.readReleasableBytesReference()but does not retain a reference to these bytes. The returnedBytesReferencethus 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:
readSlicedBytesReferencein classStreamInput- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
close
Description copied from class:StreamInputCloses the stream to further operations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classStreamInput- Throws:
IOException
-