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, writeBoolean, writeByteArray, writeBytes, writeBytes, writeBytesRef, writeBytesReference, writeDouble, writeDoubleArray, writeFloat, writeFloatArray, writeGenericValue, writeGeoPoint, writeInt, writeIntArray, writeList, writeLong, writeLongArray, writeMap, writeOptionalBoolean, writeOptionalStreamable, writeOptionalString, writeOptionalText, writeOptionalVInt, writeShort, writeString, writeStringArray, writeStringArrayNullable, writeTaskStatus, writeText, writeThrowable, writeVInt, writeVIntArray, writeVLong, writeVLongArray
write
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 IOException
position
in class StreamOutput
IOException
public void writeByte(byte b) throws IOException
StreamOutput
writeByte
in class StreamOutput
IOException
public void writeBytes(byte[] b, int offset, int length) throws IOException
StreamOutput
writeBytes
in class StreamOutput
b
- the bytes to writeoffset
- the offset in the byte arraylength
- the number of bytes to writeIOException
public void reset()
reset
in class StreamOutput
public void flush() throws IOException
StreamOutput
flush
in interface Flushable
flush
in class StreamOutput
IOException
public void seek(long position) throws IOException
seek
in class StreamOutput
IOException
public void skip(int length)
public void close() throws IOException
StreamOutput
close
in interface Closeable
close
in interface AutoCloseable
close
in class StreamOutput
IOException
public int size()
count
field, which is the number of valid
bytes in this output stream.ByteArrayOutputStream.count
public BytesReference bytes()
bytes
in interface BytesStream
public long ramBytesUsed()
ByteArray
Accountable.ramBytesUsed()
Copyright © 2009–2016. All rights reserved.