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 class org.elasticsearch.common.io.stream.StreamOutput
GENERIC_LIST_HEADERFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this stream to further operations.voidflush()Forces any buffered output to be written.org.apache.lucene.util.BytesRefget()longposition()longvoidreset()voidwriteByte(byte b) Writes a single byte.voidwriteBytes(byte[] b, int offset, int length) Writes an array of bytes.Methods inherited from class org.elasticsearch.common.io.stream.StreamOutput
checkWriteable, getTransportVersion, legacyWriteWithSizePrefix, putVInt, setTransportVersion, write, write, writeArray, writeArray, writeBigInteger, writeBoolean, writeByteArray, writeBytes, writeBytes, writeBytesRef, writeBytesReference, writeCollection, writeCollection, writeDouble, writeDoubleArray, writeDoubleLE, writeEnum, writeEnumSet, writeException, writeFloat, writeFloatArray, writeGenericList, writeGenericMap, writeGenericNull, writeGenericString, writeGenericValue, writeGeoPoint, writeInstant, writeInt, writeIntArray, writeIntLE, writeLong, writeLongArray, writeLongLE, writeMap, writeMap, writeMap, writeMapValues, writeMapValues, writeMapWithConsistentOrder, writeMissingString, writeMissingWriteable, writeNamedWriteable, writeNamedWriteableCollection, writeOptional, writeOptionalArray, writeOptionalArray, writeOptionalBoolean, writeOptionalByteArray, writeOptionalBytesReference, writeOptionalCollection, writeOptionalCollection, writeOptionalDouble, writeOptionalEnum, writeOptionalFloat, writeOptionalFloatArray, 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, writeZoneIdMethods inherited from class java.io.OutputStream
nullOutputStream, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
positionin classStreamOutput
-
writeByte
public void writeByte(byte b) Description copied from class:StreamOutputWrites a single byte.- Specified by:
writeBytein classStreamOutput
-
writeBytes
public void writeBytes(byte[] b, int offset, int length) Description copied from class:StreamOutputWrites an array of bytes.- Specified by:
writeBytesin 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:StreamOutputForces any buffered output to be written.- Specified by:
flushin interfaceFlushable- Specified by:
flushin 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classStreamOutput
-
reset
public void reset() -
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-