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, writeVLongArraywriteprotected 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 StreamOutputIOExceptionpublic void writeByte(byte b)
throws IOException
StreamOutputwriteByte in class StreamOutputIOExceptionpublic void writeBytes(byte[] b,
int offset,
int length)
throws IOException
StreamOutputwriteBytes in class StreamOutputb - the bytes to writeoffset - the offset in the byte arraylength - the number of bytes to writeIOExceptionpublic void reset()
reset in class StreamOutputpublic void flush()
throws IOException
StreamOutputflush in interface Flushableflush in class StreamOutputIOExceptionpublic void seek(long position)
throws IOException
seek in class StreamOutputIOExceptionpublic void skip(int length)
public void close()
throws IOException
StreamOutputclose in interface Closeableclose in interface AutoCloseableclose in class StreamOutputIOExceptionpublic 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()Copyright © 2009–2016. All rights reserved.