Module org.elasticsearch.server
Class RecyclerBytesStreamOutput
java.lang.Object
java.io.OutputStream
org.elasticsearch.common.io.stream.StreamOutput
org.elasticsearch.common.io.stream.BytesStream
org.elasticsearch.common.io.stream.RecyclerBytesStreamOutput
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,Releasable
A @link
StreamOutput that uses Recycler.V<org.apache.lucene.util.BytesRef> to acquire pages of bytes, which
avoids frequent reallocation & copying of the internal data. When close() is called,
the bytes will be released.-
Field Summary
Fields inherited from class org.elasticsearch.common.io.stream.StreamOutput
GENERIC_LIST_HEADER -
Constructor Summary
ConstructorsConstructorDescriptionRecyclerBytesStreamOutput(Recycler<org.apache.lucene.util.BytesRef> recycler) -
Method Summary
Modifier and TypeMethodDescriptionbytes()voidclose()Closes this stream to further operations.voidflush()Forces any buffered output to be written.longposition()voidseek(long position) intsize()Returns the current size of the buffer.voidskip(int length) voidwriteByte(byte b) Writes a single byte.voidwriteBytes(byte[] b, int offset, int length) Writes an array of bytes.voidwriteInt(int i) Writes an int as four bytes.voidwriteIntLE(int i) Writes an int as four bytes, least significant bytes first.voidwriteLong(long i) Writes a long as eight bytes.voidwriteLongLE(long i) Writes a long as eight bytes.voidwriteString(String str) voidwriteWithSizePrefix(Writeable writeable) Serializes a writable just likeWriteable.writeTo(StreamOutput)would but prefixes it with the serialized size of the result.Methods inherited from class org.elasticsearch.common.io.stream.StreamOutput
checkWriteable, getTransportVersion, 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, writeIntArray, writeLongArray, 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, writeStringArray, writeStringArrayNullable, writeStringCollection, writeText, writeTimeValue, writeVInt, writeVIntArray, writeVLong, writeVLongArray, writeWriteable, writeZLong, writeZoneIdMethods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
RecyclerBytesStreamOutput
-
-
Method Details
-
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
-
writeInt
Description copied from class:StreamOutputWrites an int as four bytes.- Overrides:
writeIntin classStreamOutput- Throws:
IOException
-
writeIntLE
Description copied from class:StreamOutputWrites an int as four bytes, least significant bytes first.- Overrides:
writeIntLEin classStreamOutput- Throws:
IOException
-
writeLong
Description copied from class:StreamOutputWrites a long as eight bytes.- Overrides:
writeLongin classStreamOutput- Throws:
IOException
-
writeLongLE
Description copied from class:StreamOutputWrites a long as eight bytes.- Overrides:
writeLongLEin classStreamOutput- Throws:
IOException
-
writeWithSizePrefix
Description copied from class:StreamOutputSerializes a writable just likeWriteable.writeTo(StreamOutput)would but prefixes it with the serialized size of the result.- Overrides:
writeWithSizePrefixin classStreamOutput- Parameters:
writeable-Writeableto serialize- Throws:
IOException
-
writeString
- Overrides:
writeStringin classStreamOutput- Throws:
IOException
-
flush
public void flush()Description copied from class:StreamOutputForces any buffered output to be written.- Specified by:
flushin interfaceFlushable- Specified by:
flushin classStreamOutput
-
seek
public void seek(long position) -
skip
public void skip(int length) -
close
public void close()Description copied from class:StreamOutputCloses this stream to further operations.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceReleasable- Specified by:
closein classStreamOutput
-
size
public int size()Returns the current size of the buffer.- Returns:
- the value of the
countfield, which is the number of valid bytes in this output stream. - See Also:
-
bytes
- Specified by:
bytesin classBytesStream
-