java.lang.Object
java.io.InputStream
org.elasticsearch.common.io.stream.StreamInput
org.elasticsearch.common.io.stream.FilterStreamInput
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
BufferedChecksumStreamInput
,NamedWriteableAwareStreamInput
Wraps a
StreamInput
and delegates to it. To be used to add functionality to an existing stream by subclassing.-
Field Summary
-
Constructor Summary
-
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.The transport version the data is serialized as.Get the registry of named writeables if this stream has one,null
otherwise.int
read()
Reads all remaining bytes in the stream as a releasable bytes reference.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.Reads a releasable bytes reference from this stream.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.long
Reads a long stored in variable-length format.void
reset()
void
setTransportVersion
(TransportVersion version) Set the transport version of the data in this stream.boolean
Checks if thisInputStream
supportsStreamInput.readAllToReleasableBytesReference()
.Methods inherited from class org.elasticsearch.common.io.stream.StreamInput
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, readOptionalArray, readOptionalBoolean, readOptionalByteArray, readOptionalBytesReference, readOptionalCollectionAsList, readOptionalDouble, readOptionalEnum, readOptionalFloat, readOptionalInstant, readOptionalInt, readOptionalLong, readOptionalNamedWriteable, readOptionalSecureString, readOptionalString, readOptionalStringArray, readOptionalStringCollectionAsList, readOptionalText, readOptionalTimeValue, readOptionalVInt, readOptionalVLong, readOptionalWriteable, readOptionalZoneId, readOrderedMap, readSecureString, readString, readStringArray, readStringCollectionAsImmutableList, readStringCollectionAsList, readText, readTimeValue, readVIntArray, readVIntSlow, readVLongArray, readVLongSlow, readZLong, readZoneId, throwEOF, throwOnBrokenVInt, throwOnBrokenVLong, throwOnNullRead, wrap, wrap
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, skipNBytes, transferTo
-
Field Details
-
delegate
-
-
Constructor Details
-
FilterStreamInput
-
-
Method Details
-
readByte
Description copied from class:StreamInput
Reads and returns a single byte.- Specified by:
readByte
in classStreamInput
- 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
-
readReleasableBytesReference
Description copied from class:StreamInput
Reads a releasable bytes reference from this stream. UnlikeStreamInput.readBytesReference()
the returned bytes reference may reference bytes in a pooled buffer and must be explicitly released viaReleasableBytesReference.close()
once no longer used. Prefer this method overStreamInput.readBytesReference()
when reading large bytes references to avoid allocations and copying.- Overrides:
readReleasableBytesReference
in classStreamInput
- Throws:
IOException
-
supportReadAllToReleasableBytesReference
public boolean supportReadAllToReleasableBytesReference()Description copied from class:StreamInput
Checks if thisInputStream
supportsStreamInput.readAllToReleasableBytesReference()
.- Overrides:
supportReadAllToReleasableBytesReference
in classStreamInput
-
readAllToReleasableBytesReference
Description copied from class:StreamInput
Reads all remaining bytes in the stream as a releasable bytes reference. Similarly toStreamInput.readReleasableBytesReference()
the returned bytes reference may reference bytes in a pooled buffer and must be explicitly released viaReleasableBytesReference.close()
once no longer used. However, unlikeStreamInput.readReleasableBytesReference()
, this method doesn't have the prefix size.NOTE: Always check
StreamInput.supportReadAllToReleasableBytesReference()
before calling this method.- Overrides:
readAllToReleasableBytesReference
in classStreamInput
- Throws:
IOException
-
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
-
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
-
readLong
Description copied from class:StreamInput
Reads eight bytes and returns a long.- Overrides:
readLong
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
-
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
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
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
-
available
- Specified by:
available
in classStreamInput
- Throws:
IOException
-
getTransportVersion
Description copied from class:StreamInput
The transport version the data is serialized as.- Overrides:
getTransportVersion
in classStreamInput
-
setTransportVersion
Description copied from class:StreamInput
Set the transport version of the data in this stream.- Overrides:
setTransportVersion
in classStreamInput
-
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
-
namedWriteableRegistry
Description copied from class:StreamInput
Get the registry of named writeables if this stream has one,null
otherwise.- Overrides:
namedWriteableRegistry
in classStreamInput
-