Module org.elasticsearch.server
Class BytesRefStreamOutput
java.lang.Object
java.io.OutputStream
org.elasticsearch.common.io.stream.StreamOutput
org.elasticsearch.common.io.stream.BytesRefStreamOutput
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,org.apache.lucene.util.Accountable
public class BytesRefStreamOutput
extends StreamOutput
implements org.apache.lucene.util.Accountable
A @link
StreamOutput
that is backed by a BytesRef
.
This is useful for small data, for larger or unknown sizes use BytesStreamOutput
instead.
Compared to BytesStreamOutput
this class avoids copying the bytes ref.
Compared to BytesRefBuilder
this class supports writing all the rich data types that StreamOutput
supports.-
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this stream to further operations.void
flush()
Forces any buffered output to be written.org.apache.lucene.util.BytesRef
get()
long
position()
long
void
reset()
void
writeByte
(byte b) Writes a single byte.void
writeBytes
(byte[] b, int offset, int length) Writes an array of bytes.Methods inherited from class org.elasticsearch.common.io.stream.StreamOutput
checkWriteable, getTransportVersion, setTransportVersion, write, write, writeArray, writeArray, writeBoolean, writeByteArray, writeBytes, writeBytes, writeBytesRef, writeBytesReference, writeCollection, writeCollection, writeDouble, writeDoubleArray, writeEnum, writeEnumSet, writeException, writeFloat, writeFloatArray, writeGenericList, writeGenericMap, writeGenericNull, writeGenericString, writeGenericValue, writeGeoPoint, writeInstant, writeInt, writeIntArray, writeList, writeLong, writeLongArray, writeMap, writeMap, writeMapOfLists, writeMapValues, writeMapValues, writeMapWithConsistentOrder, writeMissingString, writeMissingWriteable, writeNamedWriteable, writeNamedWriteableList, writeOptionalArray, writeOptionalArray, writeOptionalBoolean, writeOptionalByteArray, writeOptionalBytesReference, writeOptionalCollection, writeOptionalCollection, writeOptionalDouble, writeOptionalEnum, writeOptionalFloat, writeOptionalInstant, writeOptionalInt, writeOptionalLong, writeOptionalNamedWriteable, writeOptionalSecureString, writeOptionalString, writeOptionalStringArray, writeOptionalStringCollection, writeOptionalText, writeOptionalTimeValue, writeOptionalVInt, writeOptionalVLong, writeOptionalWriteable, writeOptionalZoneId, writeSecureString, writeShort, writeString, writeStringArray, writeStringArrayNullable, writeStringCollection, writeText, writeTimeValue, writeVInt, writeVIntArray, writeVLong, writeVLongArray, writeWithSizePrefix, writeWriteable, writeZLong, writeZoneId
Methods inherited from class java.io.OutputStream
nullOutputStream, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Constructor Details
-
BytesRefStreamOutput
public BytesRefStreamOutput()
-
-
Method Details
-
get
public org.apache.lucene.util.BytesRef get() -
position
public long position()- Overrides:
position
in classStreamOutput
-
writeByte
public void writeByte(byte b) Description copied from class:StreamOutput
Writes a single byte.- Specified by:
writeByte
in classStreamOutput
-
writeBytes
public void writeBytes(byte[] b, int offset, int length) Description copied from class:StreamOutput
Writes an array of bytes.- Specified by:
writeBytes
in classStreamOutput
- Parameters:
b
- the bytes to writeoffset
- the offset in the byte arraylength
- the number of bytes to write
-
flush
public void flush()Description copied from class:StreamOutput
Forces any buffered output to be written.- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classStreamOutput
-
close
public void close()Closes this stream to further operations. This is a no-op, as the underlying BytesRefBuilder has no IO resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classStreamOutput
-
reset
public void reset() -
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsed
in interfaceorg.apache.lucene.util.Accountable
-