public abstract class StreamInput
extends java.io.InputStream
StreamOutput. Finally
it means that the "barrier to entry" for adding new methods to this class is relatively low even though it is a shared class with code
everywhere. That being said, this class deals primarily with Lists rather than Arrays. For the most part calls should adapt to
lists, either by storing Lists internally or just converting to and from a List when calling. This comment is repeated
on StreamInput.| Constructor and Description |
|---|
StreamInput() |
| Modifier and Type | Method and Description |
|---|---|
abstract int |
available() |
abstract void |
close()
Closes the stream to further operations.
|
protected abstract void |
ensureCanReadBytes(int length)
This method throws an
EOFException 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.
|
<T> T[] |
readArray(Writeable.Reader<T> reader,
java.util.function.IntFunction<T[]> arraySupplier) |
boolean |
readBoolean()
Reads a boolean.
|
abstract byte |
readByte()
Reads and returns a single byte.
|
byte[] |
readByteArray() |
abstract void |
readBytes(byte[] b,
int offset,
int len)
Reads a specified number of bytes into an array at the specified offset.
|
org.apache.lucene.util.BytesRef |
readBytesRef() |
org.apache.lucene.util.BytesRef |
readBytesRef(int length) |
BytesReference |
readBytesReference()
Reads a bytes reference from this stream, might hold an actual reference to the underlying
bytes of the stream.
|
BytesReference |
readBytesReference(int length)
Reads a bytes reference from this stream, might hold an actual reference to the underlying
bytes of the stream.
|
double |
readDouble() |
double[] |
readDoubleArray() |
<T extends java.lang.Exception> |
readException() |
float |
readFloat() |
float[] |
readFloatArray() |
void |
readFully(byte[] b) |
java.lang.Object |
readGenericValue() |
GeoPoint |
readGeoPoint()
Reads a
GeoPoint from this stream input |
int |
readInt()
Reads four bytes and returns an int.
|
int[] |
readIntArray() |
<T> java.util.List<T> |
readList(Writeable.Reader<T> reader)
Reads a list of objects
|
long |
readLong()
Reads eight bytes and returns a long.
|
long[] |
readLongArray() |
java.util.Map<java.lang.String,java.lang.Object> |
readMap() |
<K,V> java.util.Map<K,V> |
readMap(Writeable.Reader<K> keyReader,
Writeable.Reader<V> valueReader) |
<K,V> java.util.Map<K,java.util.List<V>> |
readMapOfLists(Writeable.Reader<K> keyReader,
Writeable.Reader<V> valueReader)
Read a
Map of K-type keys to V-type Lists. |
<C extends NamedWriteable> |
readNamedWriteable(java.lang.Class<C> categoryClass)
Reads a
NamedWriteable from the current stream, by first reading its name and then looking for
the corresponding entry in the registry by name, so that the proper object can be read and returned. |
<T extends NamedWriteable> |
readNamedWriteableList(java.lang.Class<T> categoryClass)
Reads a list of
NamedWriteables. |
<T> T[] |
readOptionalArray(Writeable.Reader<T> reader,
java.util.function.IntFunction<T[]> arraySupplier) |
java.lang.Boolean |
readOptionalBoolean() |
BytesReference |
readOptionalBytesReference()
Reads an optional bytes reference from this stream.
|
java.lang.Double |
readOptionalDouble() |
java.lang.Float |
readOptionalFloat() |
java.lang.Long |
readOptionalLong() |
<C extends NamedWriteable> |
readOptionalNamedWriteable(java.lang.Class<C> categoryClass)
Reads an optional
NamedWriteable. |
<T extends Streamable> |
readOptionalStreamable(java.util.function.Supplier<T> supplier)
Serializes a potential null value.
|
java.lang.String |
readOptionalString() |
java.lang.String[] |
readOptionalStringArray() |
Text |
readOptionalText() |
org.joda.time.DateTimeZone |
readOptionalTimeZone()
Read an optional DateTimeZone.
|
java.lang.Integer |
readOptionalVInt() |
<T extends Writeable> |
readOptionalWriteable(Writeable.Reader<T> reader) |
short |
readShort() |
<T extends Streamable> |
readStreamableList(java.util.function.Supplier<T> constructor)
|
java.lang.String |
readString() |
java.lang.String[] |
readStringArray() |
Text |
readText() |
org.joda.time.DateTimeZone |
readTimeZone()
Read a DateTimeZone.
|
int |
readVInt()
Reads an int stored in variable-length format.
|
int[] |
readVIntArray() |
long |
readVLong()
Reads a long stored in variable-length format.
|
long[] |
readVLongArray() |
long |
readZLong() |
void |
setVersion(Version version)
Set the version of the node on the other side of this stream.
|
static StreamInput |
wrap(byte[] bytes) |
static StreamInput |
wrap(byte[] bytes,
int offset,
int length) |
public Version getVersion()
public void setVersion(Version version)
public abstract byte readByte()
throws java.io.IOException
java.io.IOExceptionpublic abstract void readBytes(byte[] b,
int offset,
int len)
throws java.io.IOException
b - the array to read bytes intooffset - the offset in the array to start storing byteslen - the number of bytes to readjava.io.IOExceptionpublic BytesReference readBytesReference() throws java.io.IOException
java.io.IOException@Nullable public BytesReference readOptionalBytesReference() throws java.io.IOException
readBytesReference() and
StreamOutput.writeBytesReference(BytesReference) if you do not.java.io.IOExceptionpublic BytesReference readBytesReference(int length) throws java.io.IOException
java.io.IOExceptionpublic org.apache.lucene.util.BytesRef readBytesRef()
throws java.io.IOException
java.io.IOExceptionpublic org.apache.lucene.util.BytesRef readBytesRef(int length)
throws java.io.IOException
java.io.IOExceptionpublic void readFully(byte[] b)
throws java.io.IOException
java.io.IOExceptionpublic short readShort()
throws java.io.IOException
java.io.IOExceptionpublic int readInt()
throws java.io.IOException
java.io.IOExceptionpublic int readVInt()
throws java.io.IOException
readInt()java.io.IOExceptionpublic long readLong()
throws java.io.IOException
java.io.IOExceptionpublic long readVLong()
throws java.io.IOException
java.io.IOExceptionpublic long readZLong()
throws java.io.IOException
java.io.IOException@Nullable public java.lang.Long readOptionalLong() throws java.io.IOException
java.io.IOException@Nullable public Text readOptionalText() throws java.io.IOException
java.io.IOExceptionpublic Text readText() throws java.io.IOException
java.io.IOException@Nullable public java.lang.String readOptionalString() throws java.io.IOException
java.io.IOException@Nullable public java.lang.Float readOptionalFloat() throws java.io.IOException
java.io.IOException@Nullable public java.lang.Integer readOptionalVInt() throws java.io.IOException
java.io.IOExceptionpublic java.lang.String readString()
throws java.io.IOException
java.io.IOExceptionpublic final float readFloat()
throws java.io.IOException
java.io.IOExceptionpublic final double readDouble()
throws java.io.IOException
java.io.IOException@Nullable public final java.lang.Double readOptionalDouble() throws java.io.IOException
java.io.IOExceptionpublic final boolean readBoolean()
throws java.io.IOException
java.io.IOException@Nullable public final java.lang.Boolean readOptionalBoolean() throws java.io.IOException
java.io.IOExceptionpublic abstract void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic abstract int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionpublic java.lang.String[] readStringArray()
throws java.io.IOException
java.io.IOException@Nullable public java.lang.String[] readOptionalStringArray() throws java.io.IOException
java.io.IOExceptionpublic <K,V> java.util.Map<K,V> readMap(Writeable.Reader<K> keyReader, Writeable.Reader<V> valueReader) throws java.io.IOException
java.io.IOExceptionpublic <K,V> java.util.Map<K,java.util.List<V>> readMapOfLists(Writeable.Reader<K> keyReader, Writeable.Reader<V> valueReader) throws java.io.IOException
Map of K-type keys to V-type Lists.
Map<String, List<String>> map = in.readMapOfLists(StreamInput::readString, StreamInput::readString);
keyReader - The key readervalueReader - The value readernull.java.io.IOException@Nullable public java.util.Map<java.lang.String,java.lang.Object> readMap() throws java.io.IOException
java.io.IOException@Nullable public java.lang.Object readGenericValue() throws java.io.IOException
java.io.IOExceptionpublic GeoPoint readGeoPoint() throws java.io.IOException
GeoPoint from this stream inputjava.io.IOExceptionpublic org.joda.time.DateTimeZone readTimeZone()
throws java.io.IOException
java.io.IOExceptionpublic org.joda.time.DateTimeZone readOptionalTimeZone()
throws java.io.IOException
java.io.IOExceptionpublic int[] readIntArray()
throws java.io.IOException
java.io.IOExceptionpublic int[] readVIntArray()
throws java.io.IOException
java.io.IOExceptionpublic long[] readLongArray()
throws java.io.IOException
java.io.IOExceptionpublic long[] readVLongArray()
throws java.io.IOException
java.io.IOExceptionpublic float[] readFloatArray()
throws java.io.IOException
java.io.IOExceptionpublic double[] readDoubleArray()
throws java.io.IOException
java.io.IOExceptionpublic byte[] readByteArray()
throws java.io.IOException
java.io.IOExceptionpublic <T> T[] readArray(Writeable.Reader<T> reader, java.util.function.IntFunction<T[]> arraySupplier) throws java.io.IOException
java.io.IOExceptionpublic <T> T[] readOptionalArray(Writeable.Reader<T> reader, java.util.function.IntFunction<T[]> arraySupplier) throws java.io.IOException
java.io.IOException@Nullable public <T extends Streamable> T readOptionalStreamable(java.util.function.Supplier<T> supplier) throws java.io.IOException
java.io.IOException@Nullable public <T extends Writeable> T readOptionalWriteable(Writeable.Reader<T> reader) throws java.io.IOException
java.io.IOExceptionpublic <T extends java.lang.Exception> T readException()
throws java.io.IOException
java.io.IOException@Nullable public <C extends NamedWriteable> C readNamedWriteable(java.lang.Class<C> categoryClass) throws java.io.IOException
NamedWriteable from the current stream, by first reading its name and then looking for
the corresponding entry in the registry by name, so that the proper object can be read and returned.
Default implementation throws UnsupportedOperationException as StreamInput doesn't hold a registry.
Use FilterInputStream instead which wraps a stream and supports a NamedWriteableRegistry too.java.io.IOException@Nullable public <C extends NamedWriteable> C readOptionalNamedWriteable(java.lang.Class<C> categoryClass) throws java.io.IOException
NamedWriteable.java.io.IOExceptionpublic <T extends Streamable> java.util.List<T> readStreamableList(java.util.function.Supplier<T> constructor) throws java.io.IOException
List of Streamable objects, using the constructor to instantiate each instance.
This is expected to take the form:
List<MyStreamableClass> list = in.readStreamList(MyStreamableClass::new);
constructor - Streamable instance creatornull.java.io.IOException - if any step failspublic <T> java.util.List<T> readList(Writeable.Reader<T> reader) throws java.io.IOException
java.io.IOExceptionpublic <T extends NamedWriteable> java.util.List<T> readNamedWriteableList(java.lang.Class<T> categoryClass) throws java.io.IOException
NamedWriteables.java.io.IOExceptionpublic static StreamInput wrap(byte[] bytes)
public static StreamInput wrap(byte[] bytes, int offset, int length)
protected abstract void ensureCanReadBytes(int length)
throws java.io.EOFException
EOFException 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.java.io.EOFException