public class BytesStreamOutput extends 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, writeEnum, 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, writeZLong
protected 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 StreamOutput
java.io.IOException
public void writeByte(byte b) throws java.io.IOException
StreamOutput
writeByte
in class StreamOutput
java.io.IOException
public void writeBytes(byte[] b, int offset, int length)
StreamOutput
writeBytes
in class StreamOutput
b
- the bytes to writeoffset
- the offset in the byte arraylength
- the number of bytes to writepublic void reset()
reset
in class StreamOutput
public void flush() throws java.io.IOException
StreamOutput
flush
in interface java.io.Flushable
flush
in class StreamOutput
java.io.IOException
public void seek(long position)
seek
in class StreamOutput
public void skip(int length)
public void close()
StreamOutput
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class StreamOutput
public int size()
count
field, which is the number of valid
bytes in this output stream.ByteArrayOutputStream.count
public BytesReference bytes()
bytes
in class BytesStream
public long ramBytesUsed()
ByteArray
Accountable.ramBytesUsed()