java.lang.Object
java.io.OutputStream
org.elasticsearch.common.io.stream.StreamOutput
org.elasticsearch.common.io.stream.BytesStream
org.elasticsearch.common.io.stream.BytesStreamOutput
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
- Direct Known Subclasses:
ReleasableBytesStreamOutput
A @link
StreamOutput that uses BigArrays to acquire pages of
bytes, which avoids frequent reallocation & copying of the internal data.-
Field Summary
FieldsFields inherited from class org.elasticsearch.common.io.stream.StreamOutput
GENERIC_LIST_HEADER -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate a non recyclingBytesStreamOutputwith an initial capacity of 0.BytesStreamOutput(int expectedSize) Create a non recyclingBytesStreamOutputwith enough initial pages acquired to satisfy the capacity given by expected size.protectedBytesStreamOutput(int expectedSize, BigArrays bigArrays) -
Method Summary
Modifier and TypeMethodDescriptionbytes()voidclose()Closes this stream to further operations.Likebytes()but copies the bytes to a freshly allocated buffer.protected voidensureCapacity(long offset) voidflush()Forces any buffered output to be written.longposition()voidreset()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.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, 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, write
-
Field Details
-
bigArrays
-
bytes
-
count
protected int count
-
-
Constructor Details
-
BytesStreamOutput
public BytesStreamOutput()Create a non recyclingBytesStreamOutputwith an initial capacity of 0. -
BytesStreamOutput
public BytesStreamOutput(int expectedSize) Create a non recyclingBytesStreamOutputwith enough initial pages acquired to satisfy the capacity given by expected size.- Parameters:
expectedSize- the expected maximum size of the stream in bytes.
-
BytesStreamOutput
-
-
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
-
reset
public void reset() -
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 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
-
copyBytes
Likebytes()but copies the bytes to a freshly allocated buffer.- Returns:
- copy of the bytes in this instances
-
ensureCapacity
protected void ensureCapacity(long offset)
-