public 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 List
s rather than Arrays. For the most part calls should adapt to
lists, either by storing List
s internally or just converting to and from a List
when calling. This comment is repeated
on StreamInput
.Constructor and Description |
---|
StreamOutput() |
Modifier and Type | Method and 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 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) |
<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. |
void |
writeMap(java.util.Map<java.lang.String,java.lang.Object> map) |
<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 List s. |
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.IOException
public void seek(long position) throws java.io.IOException
java.io.IOException
public abstract void writeByte(byte b) throws java.io.IOException
java.io.IOException
public void writeBytes(byte[] b) throws java.io.IOException
b
- the bytes to writejava.io.IOException
public void writeBytes(byte[] b, int length) throws java.io.IOException
b
- the bytes to writelength
- the number of bytes to writejava.io.IOException
public 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.IOException
public void writeByteArray(byte[] b) throws java.io.IOException
b
- the bytes to writejava.io.IOException
public void writeBytesReference(@Nullable BytesReference bytes) throws java.io.IOException
java.io.IOException
public void writeOptionalBytesReference(@Nullable BytesReference bytes) throws java.io.IOException
writeBytesReference(BytesReference)
and StreamInput.readBytesReference()
if you do not.java.io.IOException
public void writeBytesRef(org.apache.lucene.util.BytesRef bytes) throws java.io.IOException
java.io.IOException
public final void writeShort(short v) throws java.io.IOException
java.io.IOException
public void writeInt(int i) throws java.io.IOException
java.io.IOException
public void writeVInt(int i) throws java.io.IOException
writeInt(int)
java.io.IOException
public void writeLong(long i) throws java.io.IOException
java.io.IOException
public void writeVLong(long i) throws java.io.IOException
writeLong(long)
or writeZLong(long)
for
negative numbers.java.io.IOException
public void writeZLong(long i) throws java.io.IOException
writeVLong(long)
java.io.IOException
public void writeOptionalLong(@Nullable java.lang.Long l) throws java.io.IOException
java.io.IOException
public void writeOptionalString(@Nullable java.lang.String str) throws java.io.IOException
java.io.IOException
public void writeOptionalVInt(@Nullable java.lang.Integer integer) throws java.io.IOException
java.io.IOException
public void writeOptionalFloat(@Nullable java.lang.Float floatValue) throws java.io.IOException
java.io.IOException
public void writeOptionalText(@Nullable Text text) throws java.io.IOException
java.io.IOException
public void writeText(Text text) throws java.io.IOException
java.io.IOException
public void writeString(java.lang.String str) throws java.io.IOException
java.io.IOException
public void writeFloat(float v) throws java.io.IOException
java.io.IOException
public void writeDouble(double v) throws java.io.IOException
java.io.IOException
public void writeOptionalDouble(@Nullable java.lang.Double v) throws java.io.IOException
java.io.IOException
public void writeBoolean(boolean b) throws java.io.IOException
java.io.IOException
public void writeOptionalBoolean(@Nullable java.lang.Boolean b) throws java.io.IOException
java.io.IOException
public abstract void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public abstract void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
public abstract void reset() throws java.io.IOException
java.io.IOException
public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void writeStringArray(java.lang.String[] array) throws java.io.IOException
java.io.IOException
public void writeStringArrayNullable(@Nullable java.lang.String[] array) throws java.io.IOException
java.io.IOException
public void writeOptionalStringArray(@Nullable java.lang.String[] array) throws java.io.IOException
java.io.IOException
public void writeMap(@Nullable java.util.Map<java.lang.String,java.lang.Object> map) throws java.io.IOException
java.io.IOException
public 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.IOException
public 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 List
s.
Map<String, List<String>> map = ...;
out.writeMapOfLists(map, StreamOutput::writeString, StreamOutput::writeString);
keyWriter
- The key writervalueWriter
- The value writerjava.io.IOException
public 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.IOException
public void writeGenericValue(@Nullable java.lang.Object value) throws java.io.IOException
writeMapWithConsistentOrder
java.io.IOException
public void writeIntArray(int[] values) throws java.io.IOException
java.io.IOException
public void writeVIntArray(int[] values) throws java.io.IOException
java.io.IOException
public void writeLongArray(long[] values) throws java.io.IOException
java.io.IOException
public void writeVLongArray(long[] values) throws java.io.IOException
java.io.IOException
public void writeFloatArray(float[] values) throws java.io.IOException
java.io.IOException
public void writeDoubleArray(double[] values) throws java.io.IOException
java.io.IOException
public <T extends Writeable> void writeArray(T[] array) throws java.io.IOException
java.io.IOException
public <T extends Writeable> void writeOptionalArray(@Nullable T[] array) throws java.io.IOException
java.io.IOException
public void writeOptionalStreamable(@Nullable Streamable streamable) throws java.io.IOException
java.io.IOException
public void writeOptionalWriteable(@Nullable Writeable writeable) throws java.io.IOException
java.io.IOException
public void writeException(java.lang.Throwable throwable) throws java.io.IOException
java.io.IOException
public void writeNamedWriteable(NamedWriteable namedWriteable) throws java.io.IOException
NamedWriteable
to the current stream, by first writing its name and then the object itselfjava.io.IOException
public void writeOptionalNamedWriteable(@Nullable NamedWriteable namedWriteable) throws java.io.IOException
NamedWriteable
to the stream.java.io.IOException
public void writeGeoPoint(GeoPoint geoPoint) throws java.io.IOException
GeoPoint
to the streamjava.io.IOException
public void writeTimeZone(org.joda.time.DateTimeZone timeZone) throws java.io.IOException
java.io.IOException
public void writeOptionalTimeZone(@Nullable org.joda.time.DateTimeZone timeZone) throws java.io.IOException
java.io.IOException
public void writeStreamableList(java.util.List<? extends Streamable> list) throws java.io.IOException
Streamable
objectsjava.io.IOException
public void writeList(java.util.List<? extends Writeable> list) throws java.io.IOException
Writeable
objectsjava.io.IOException
public void writeStringList(java.util.List<java.lang.String> list) throws java.io.IOException
java.io.IOException
public void writeNamedWriteableList(java.util.List<? extends NamedWriteable> list) throws java.io.IOException
NamedWriteable
objects.java.io.IOException
public <E extends java.lang.Enum<E>> void writeEnum(E enumValue) throws java.io.IOException
java.io.IOException