Class FilterStreamInput
java.lang.Object
java.io.InputStream
org.elasticsearch.common.io.stream.StreamInput
org.elasticsearch.common.io.stream.FilterStreamInput
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
BufferedChecksumStreamInput
,NamedWriteableAwareStreamInput
public abstract class FilterStreamInput extends StreamInput
Wraps a
StreamInput
and delegates to it. To be used to add functionality to an existing stream by subclassing.-
Field Summary
Fields Modifier and Type Field Description protected StreamInput
delegate
-
Constructor Summary
Constructors Modifier Constructor Description protected
FilterStreamInput(StreamInput delegate)
-
Method Summary
Modifier and Type Method Description int
available()
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 this stream.Version
getVersion()
The version of the node on the other side of this stream.NamedWriteableRegistry
namedWriteableRegistry()
Get the registry of named writeables if this stream has one,null
otherwise.int
read()
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.ReleasableBytesReference
readReleasableBytesReference()
Reads a releasable bytes reference from this stream.short
readShort()
int
readVInt()
Reads an int stored in variable-length format.long
readVLong()
Reads a long stored in variable-length format.void
reset()
void
setVersion(Version version)
Set the version of the node on the other side of this stream.Methods inherited from class org.elasticsearch.common.io.stream.StreamInput
readArray, readArraySize, readBigInteger, readBoolean, readByteArray, readBytesRef, readBytesRef, readBytesReference, readBytesReference, readDouble, readDoubleArray, readEnum, readEnumSet, readException, readFloat, readFloatArray, readFully, readGenericValue, readGeoPoint, readImmutableMap, readInstant, readIntArray, readList, readLongArray, readMap, readMap, readMapOfLists, readNamedWriteable, readNamedWriteable, readNamedWriteableList, readOptionalArray, readOptionalBoolean, readOptionalBytesReference, readOptionalDouble, readOptionalEnum, readOptionalFloat, readOptionalInstant, readOptionalInt, readOptionalLong, readOptionalNamedWriteable, readOptionalSecureString, readOptionalString, readOptionalStringArray, readOptionalStringList, readOptionalText, readOptionalTimeValue, readOptionalTimeZone, readOptionalVInt, readOptionalVLong, readOptionalWriteable, readOptionalZoneId, readOrderedMap, readSecureString, readSet, readString, readStringArray, readStringList, readText, readTimeValue, readTimeZone, readVIntArray, readVIntSlow, readVLongArray, readVLongSlow, readZLong, readZoneId, throwOnBrokenVInt, throwOnBrokenVLong, wrap, wrap
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, skipNBytes, transferTo
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
delegate
-
-
Constructor Details
-
FilterStreamInput
-
-
Method Details
-
readByte
public byte readByte() throws java.io.IOExceptionDescription copied from class:StreamInput
Reads and returns a single byte.- Specified by:
readByte
in classStreamInput
- Throws:
java.io.IOException
-
readBytes
public void readBytes(byte[] b, int offset, int len) throws java.io.IOExceptionDescription 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:
java.io.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:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOException- Overrides:
readShort
in classStreamInput
- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOExceptionDescription copied from class:StreamInput
Reads four bytes and returns an int.- Overrides:
readInt
in classStreamInput
- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOExceptionDescription copied from class:StreamInput
Reads eight bytes and returns a long.- Overrides:
readLong
in classStreamInput
- Throws:
java.io.IOException
-
readVInt
public int readVInt() throws java.io.IOExceptionDescription 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:
java.io.IOException
-
readVLong
public long readVLong() throws java.io.IOExceptionDescription 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:
java.io.IOException
-
reset
public void reset() throws java.io.IOException- Overrides:
reset
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionDescription copied from class:StreamInput
Closes the stream to further operations.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classStreamInput
- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Specified by:
available
in classStreamInput
- Throws:
java.io.IOException
-
getVersion
Description copied from class:StreamInput
The version of the node on the other side of this stream.- Overrides:
getVersion
in classStreamInput
-
setVersion
Description copied from class:StreamInput
Set the version of the node on the other side of this stream.- Overrides:
setVersion
in classStreamInput
-
ensureCanReadBytes
protected void ensureCanReadBytes(int length) throws java.io.EOFExceptionDescription copied from class:StreamInput
This method throws anEOFException
if the given number of bytes can not be read from the this 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:
java.io.EOFException
-
namedWriteableRegistry
Description copied from class:StreamInput
Get the registry of named writeables if this stream has one,null
otherwise.- Overrides:
namedWriteableRegistry
in classStreamInput
-