public class BytesStreamOutput extends StreamOutput implements BytesStream
StreamOutput that uses BigArrays to acquire pages of
bytes, which avoids frequent reallocation & copying of the internal data.| Modifier and Type | Field and Description |
|---|---|
protected BigArrays |
bigArrays |
protected ByteArray |
bytes |
protected int |
count |
| Modifier | Constructor and Description |
|---|---|
|
BytesStreamOutput()
Create a non recycling
BytesStreamOutput with an initial capacity of 0. |
|
BytesStreamOutput(int expectedSize)
Create a non recycling
BytesStreamOutput with enough initial pages acquired
to satisfy the capacity given by expected size. |
protected |
BytesStreamOutput(int expectedSize,
BigArrays bigArrays) |
| Modifier and Type | Method and Description |
|---|---|
BytesReference |
bytes() |
void |
close()
Closes this stream to further operations.
|
void |
flush()
Forces any buffered output to be written.
|
long |
position() |
long |
ramBytesUsed()
Returns the number of bytes used by the underlying
ByteArray |
void |
reset() |
void |
seek(long position) |
int |
size()
Returns the current size of the buffer.
|
void |
skip(int length) |
void |
writeByte(byte b)
Writes a single byte.
|
void |
writeBytes(byte[] b,
int offset,
int length)
Writes an array of bytes.
|
getVersion, setVersion, write, write, writeArray, writeBoolean, writeByteArray, writeBytes, writeBytes, writeBytesRef, writeBytesReference, writeDouble, writeDoubleArray, writeException, writeFloat, writeFloatArray, writeGenericValue, writeGeoPoint, writeInt, writeIntArray, writeList, writeLong, writeLongArray, writeMap, writeMap, writeMapOfLists, writeMapWithConsistentOrder, writeNamedWriteable, writeNamedWriteableList, writeOptionalArray, writeOptionalBoolean, writeOptionalBytesReference, writeOptionalDouble, writeOptionalFloat, writeOptionalLong, writeOptionalNamedWriteable, writeOptionalStreamable, writeOptionalString, writeOptionalStringArray, writeOptionalText, writeOptionalTimeZone, writeOptionalVInt, writeOptionalWriteable, writeShort, writeStreamableList, writeString, writeStringArray, writeStringArrayNullable, writeStringList, writeText, writeTimeZone, writeVInt, writeVIntArray, writeVLong, writeVLongArray, writeZLongprotected final BigArrays bigArrays
protected ByteArray bytes
protected int count
public BytesStreamOutput()
BytesStreamOutput with an initial capacity of 0.public BytesStreamOutput(int expectedSize)
BytesStreamOutput with enough initial pages acquired
to satisfy the capacity given by expected size.expectedSize - the expected maximum size of the stream in bytes.protected BytesStreamOutput(int expectedSize,
BigArrays bigArrays)
public long position()
throws java.io.IOException
position in class StreamOutputjava.io.IOExceptionpublic void writeByte(byte b)
throws java.io.IOException
StreamOutputwriteByte in class StreamOutputjava.io.IOExceptionpublic void writeBytes(byte[] b,
int offset,
int length)
StreamOutputwriteBytes in class StreamOutputb - the bytes to writeoffset - the offset in the byte arraylength - the number of bytes to writepublic void reset()
reset in class StreamOutputpublic void flush()
throws java.io.IOException
StreamOutputflush in interface java.io.Flushableflush in class StreamOutputjava.io.IOExceptionpublic void seek(long position)
seek in class StreamOutputpublic void skip(int length)
public void close()
StreamOutputclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class StreamOutputpublic int size()
count field, which is the number of valid
bytes in this output stream.ByteArrayOutputStream.countpublic BytesReference bytes()
bytes in interface BytesStreampublic long ramBytesUsed()
ByteArrayAccountable.ramBytesUsed()