BufferedChecksumStreamOutput, BytesStream, DataOutputStreamOutput, OutputStreamStreamOutputpublic abstract class StreamOutput
extends java.io.OutputStream
StreamInput. 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 | Description |
|---|---|
StreamOutput() |
| Modifier and Type | Method | Description |
|---|---|---|
abstract void |
close() |
Closes this stream to further operations.
|
abstract void |
flush() |
Forces any buffered output to be written.
|
Version |
getVersion() |
The version of the node on the other side of this stream.
|
long |
position() |
|
abstract void |
reset() |
|
void |
seek(long position) |
|
void |
setVersion(Version version) |
Set the version of the node on the other side of this stream.
|
void |
write(byte[] b,
int off,
int len) |
|
void |
write(int b) |
|
<T> void |
writeArray(Writeable.Writer<T> writer,
T[] array) |
Writes the specified array to the stream using the specified
Writeable.Writer for each element in the array. |
<T extends Writeable> |
writeArray(T[] array) |
|
void |
writeBoolean(boolean b) |
Writes a boolean.
|
abstract void |
writeByte(byte b) |
Writes a single byte.
|
void |
writeByteArray(byte[] b) |
Writes an array of bytes.
|
void |
writeBytes(byte[] b) |
Writes an array of bytes.
|
void |
writeBytes(byte[] b,
int length) |
Writes an array of bytes.
|
abstract void |
writeBytes(byte[] b,
int offset,
int length) |
Writes an array of bytes.
|
void |
writeBytesRef(org.apache.lucene.util.BytesRef bytes) |
|
void |
writeBytesReference(BytesReference bytes) |
Writes the bytes reference, including a length header.
|
void |
writeDouble(double v) |
|
void |
writeDoubleArray(double[] values) |
|
<E extends java.lang.Enum<E>> |
writeEnum(E enumValue) |
Writes an enum with type E that by serialized it based on it's ordinal value
|
void |
writeException(java.lang.Throwable throwable) |
|
void |
writeFloat(float v) |
|
void |
writeFloatArray(float[] values) |
|
void |
writeGenericValue(java.lang.Object value) |
Notice: when serialization a map, the stream out map with the stream in map maybe have the
different key-value orders, they will maybe have different stream order.
|
void |
writeGeoPoint(GeoPoint geoPoint) |
Writes the given
GeoPoint to the stream |
void |
writeInt(int i) |
Writes an int as four bytes.
|
void |
writeIntArray(int[] values) |
|
void |
writeList(java.util.List<? extends Writeable> list) |
Writes a list of
Writeable objects |
void |
writeLong(long i) |
Writes a long as eight bytes.
|
void |
writeLongArray(long[] values) |
|
void |
writeMap(java.util.Map<java.lang.String,java.lang.Object> map) |
|
<K,V> void |
writeMap(java.util.Map<K,V> map,
Writeable.Writer<K> keyWriter,
Writeable.Writer<V> valueWriter) |
Write a
Map of K-type keys to V-type. |
<K,V> void |
writeMapOfLists(java.util.Map<K,java.util.List<V>> map,
Writeable.Writer<K> keyWriter,
Writeable.Writer<V> valueWriter) |
Write a
Map of K-type keys to V-type Lists. |
void |
writeMapWithConsistentOrder(java.util.Map<java.lang.String,? extends java.lang.Object> map) |
write map to stream with consistent order
to make sure every map generated bytes order are same.
|
void |
writeNamedWriteable(NamedWriteable namedWriteable) |
Writes a
NamedWriteable to the current stream, by first writing its name and then the object itself |
void |
writeNamedWriteableList(java.util.List<? extends NamedWriteable> list) |
Writes a list of
NamedWriteable objects. |
<T extends Writeable> |
writeOptionalArray(T[] array) |
|
void |
writeOptionalBoolean(java.lang.Boolean b) |
|
void |
writeOptionalBytesReference(BytesReference bytes) |
Writes an optional bytes reference including a length header.
|
void |
writeOptionalDouble(java.lang.Double v) |
|
void |
writeOptionalFloat(java.lang.Float floatValue) |
|
void |
writeOptionalLong(java.lang.Long l) |
|
void |
writeOptionalNamedWriteable(NamedWriteable namedWriteable) |
Write an optional
NamedWriteable to the stream. |
void |
writeOptionalStreamable(Streamable streamable) |
Serializes a potential null value.
|
void |
writeOptionalString(java.lang.String str) |
|
void |
writeOptionalStringArray(java.lang.String[] array) |
Writes a string array, for nullable string, writes false.
|
void |
writeOptionalText(Text text) |
|
void |
writeOptionalTimeZone(org.joda.time.DateTimeZone timeZone) |
Write an optional DateTimeZone to the stream.
|
void |
writeOptionalVInt(java.lang.Integer integer) |
|
void |
writeOptionalWriteable(Writeable writeable) |
|
void |
writeShort(short v) |
|
void |
writeStreamableList(java.util.List<? extends Streamable> list) |
Writes a list of
Streamable objects |
void |
writeString(java.lang.String str) |
|
void |
writeStringArray(java.lang.String[] array) |
|
void |
writeStringArrayNullable(java.lang.String[] array) |
Writes a string array, for nullable string, writes it as 0 (empty string).
|
void |
writeStringList(java.util.List<java.lang.String> list) |
Writes a list of strings
|
void |
writeText(Text text) |
|
void |
writeTimeZone(org.joda.time.DateTimeZone timeZone) |
Write a DateTimeZone to the stream.
|
void |
writeVInt(int i) |
Writes an int in a variable-length format.
|
void |
writeVIntArray(int[] values) |
|
void |
writeVLong(long i) |
Writes a non-negative long in a variable-length format.
|
void |
writeVLongArray(long[] values) |
|
void |
writeZLong(long i) |
Writes a long in a variable-length format.
|
public Version getVersion()
public void setVersion(Version version)
public long position()
throws java.io.IOException
java.io.IOExceptionpublic void seek(long position)
throws java.io.IOException
java.io.IOExceptionpublic abstract void writeByte(byte b)
throws java.io.IOException
java.io.IOExceptionpublic void writeBytes(byte[] b)
throws java.io.IOException
b - the bytes to writejava.io.IOExceptionpublic void writeBytes(byte[] b,
int length)
throws java.io.IOException
b - the bytes to writelength - the number of bytes to writejava.io.IOExceptionpublic abstract void writeBytes(byte[] b,
int offset,
int length)
throws java.io.IOException
b - the bytes to writeoffset - the offset in the byte arraylength - the number of bytes to writejava.io.IOExceptionpublic void writeByteArray(byte[] b)
throws java.io.IOException
b - the bytes to writejava.io.IOExceptionpublic void writeBytesReference(@Nullable BytesReference bytes) throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalBytesReference(@Nullable BytesReference bytes) throws java.io.IOException
writeBytesReference(BytesReference) and StreamInput.readBytesReference() if you do not.java.io.IOExceptionpublic void writeBytesRef(org.apache.lucene.util.BytesRef bytes)
throws java.io.IOException
java.io.IOExceptionpublic final void writeShort(short v)
throws java.io.IOException
java.io.IOExceptionpublic void writeInt(int i)
throws java.io.IOException
java.io.IOExceptionpublic void writeVInt(int i)
throws java.io.IOException
writeInt(int)java.io.IOExceptionpublic void writeLong(long i)
throws java.io.IOException
java.io.IOExceptionpublic void writeVLong(long i)
throws java.io.IOException
writeLong(long) or writeZLong(long) for
negative numbers.java.io.IOExceptionpublic void writeZLong(long i)
throws java.io.IOException
writeVLong(long)java.io.IOExceptionpublic void writeOptionalLong(@Nullable java.lang.Long l) throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalString(@Nullable java.lang.String str) throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalVInt(@Nullable java.lang.Integer integer) throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalFloat(@Nullable java.lang.Float floatValue) throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalText(@Nullable Text text) throws java.io.IOException
java.io.IOExceptionpublic void writeText(Text text) throws java.io.IOException
java.io.IOExceptionpublic void writeString(java.lang.String str)
throws java.io.IOException
java.io.IOExceptionpublic void writeFloat(float v)
throws java.io.IOException
java.io.IOExceptionpublic void writeDouble(double v)
throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalDouble(@Nullable java.lang.Double v) throws java.io.IOException
java.io.IOExceptionpublic void writeBoolean(boolean b)
throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalBoolean(@Nullable java.lang.Boolean b) throws java.io.IOException
java.io.IOExceptionpublic abstract void flush()
throws java.io.IOException
flush in class java.io.OutputStreamjava.io.IOExceptionpublic abstract void close()
throws java.io.IOException
close in class java.io.OutputStreamjava.io.IOExceptionpublic abstract void reset()
throws java.io.IOException
java.io.IOExceptionpublic void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void writeStringArray(java.lang.String[] array)
throws java.io.IOException
java.io.IOExceptionpublic void writeStringArrayNullable(@Nullable java.lang.String[] array) throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalStringArray(@Nullable java.lang.String[] array) throws java.io.IOException
java.io.IOExceptionpublic void writeMap(@Nullable java.util.Map<java.lang.String,java.lang.Object> map) throws java.io.IOException
java.io.IOExceptionpublic void writeMapWithConsistentOrder(@Nullable java.util.Map<java.lang.String,? extends java.lang.Object> map) throws java.io.IOException
StreamInput.readMap and StreamInput.readGenericValue
This method only will handle the map keys order, not maps contained within the mapjava.io.IOExceptionpublic final <K,V> void writeMapOfLists(java.util.Map<K,java.util.List<V>> map,
Writeable.Writer<K> keyWriter,
Writeable.Writer<V> valueWriter)
throws java.io.IOException
Map of K-type keys to V-type Lists.
Map<String, List<String>> map = ...;
out.writeMapOfLists(map, StreamOutput::writeString, StreamOutput::writeString);
keyWriter - The key writervalueWriter - The value writerjava.io.IOExceptionpublic final <K,V> void writeMap(java.util.Map<K,V> map,
Writeable.Writer<K> keyWriter,
Writeable.Writer<V> valueWriter)
throws java.io.IOException
Map of K-type keys to V-type.
Map<String, String> map = ...;
out.writeMap(map, StreamOutput::writeString, StreamOutput::writeString);
keyWriter - The key writervalueWriter - The value writerjava.io.IOExceptionpublic void writeGenericValue(@Nullable java.lang.Object value) throws java.io.IOException
writeMapWithConsistentOrderjava.io.IOExceptionpublic void writeIntArray(int[] values)
throws java.io.IOException
java.io.IOExceptionpublic void writeVIntArray(int[] values)
throws java.io.IOException
java.io.IOExceptionpublic void writeLongArray(long[] values)
throws java.io.IOException
java.io.IOExceptionpublic void writeVLongArray(long[] values)
throws java.io.IOException
java.io.IOExceptionpublic void writeFloatArray(float[] values)
throws java.io.IOException
java.io.IOExceptionpublic void writeDoubleArray(double[] values)
throws java.io.IOException
java.io.IOExceptionpublic <T> void writeArray(Writeable.Writer<T> writer, T[] array) throws java.io.IOException
Writeable.Writer for each element in the array. This method can be seen as
writer version of StreamInput.readArray(Writeable.Reader, IntFunction). The length of array encoded as a variable-length
integer is first written to the stream, and then the elements of the array are written to the stream.T - the type of the elements of the arraywriter - the writer used to write individual elementsarray - the arrayjava.io.IOException - if an I/O exception occurs while writing the arraypublic <T extends Writeable> void writeArray(T[] array) throws java.io.IOException
java.io.IOExceptionpublic <T extends Writeable> void writeOptionalArray(@Nullable T[] array) throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalStreamable(@Nullable Streamable streamable) throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalWriteable(@Nullable Writeable writeable) throws java.io.IOException
java.io.IOExceptionpublic void writeException(java.lang.Throwable throwable)
throws java.io.IOException
java.io.IOExceptionpublic void writeNamedWriteable(NamedWriteable namedWriteable) throws java.io.IOException
NamedWriteable to the current stream, by first writing its name and then the object itselfjava.io.IOExceptionpublic void writeOptionalNamedWriteable(@Nullable NamedWriteable namedWriteable) throws java.io.IOException
NamedWriteable to the stream.java.io.IOExceptionpublic void writeGeoPoint(GeoPoint geoPoint) throws java.io.IOException
GeoPoint to the streamjava.io.IOExceptionpublic void writeTimeZone(org.joda.time.DateTimeZone timeZone)
throws java.io.IOException
java.io.IOExceptionpublic void writeOptionalTimeZone(@Nullable org.joda.time.DateTimeZone timeZone) throws java.io.IOException
java.io.IOExceptionpublic void writeStreamableList(java.util.List<? extends Streamable> list) throws java.io.IOException
Streamable objectsjava.io.IOExceptionpublic void writeList(java.util.List<? extends Writeable> list) throws java.io.IOException
Writeable objectsjava.io.IOExceptionpublic void writeStringList(java.util.List<java.lang.String> list)
throws java.io.IOException
java.io.IOExceptionpublic void writeNamedWriteableList(java.util.List<? extends NamedWriteable> list) throws java.io.IOException
NamedWriteable objects.java.io.IOExceptionpublic <E extends java.lang.Enum<E>> void writeEnum(E enumValue)
throws java.io.IOException
java.io.IOException