public class FastMemoryOutputTransport
extends org.apache.thrift.transport.TTransport
Modifier and Type | Field and Description |
---|---|
protected Buffer |
buf
The byte array containing the bytes written.
|
protected int |
count
The number of bytes written.
|
protected int |
streamPos |
Constructor and Description |
---|
FastMemoryOutputTransport(int size,
boolean useHeapBasedAllocation)
Constructs a new
FastMemoryOutputTransport with a default size of
size bytes. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this transport.
|
boolean |
isFullyStreamed() |
boolean |
isOpen() |
void |
open() |
int |
read(byte[] buf,
int off,
int len) |
int |
size()
Returns the total number of bytes written to this transport so far.
|
int |
streamTo(org.apache.thrift.transport.TNonblockingTransport transport)
Start writing accumulated content to the given transport
or continue from the previous stop point (this method is stateful).
|
String |
toString()
Returns the contents of this ByteArrayOutputStream as a string.
|
void |
write(byte[] buffer,
int offset,
int len)
Writes
count bytes from the byte buffer buffer starting at
offset index to this stream. |
protected Buffer buf
protected int count
protected int streamPos
public FastMemoryOutputTransport(int size, boolean useHeapBasedAllocation)
FastMemoryOutputTransport
with a default size of
size
bytes. If more than size
bytes are written to this
instance, the underlying byte buffer will expanded.size
- initial size for the underlying byte buffer, must be non-negative.useHeapBasedAllocation
- Flag to trigger ByteBuffer.allocate(int) or off-heap memory allocation for storage.IllegalArgumentException
- if size
< 0.public boolean isOpen()
isOpen
in class org.apache.thrift.transport.TTransport
public void open() throws org.apache.thrift.transport.TTransportException
open
in class org.apache.thrift.transport.TTransport
org.apache.thrift.transport.TTransportException
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class org.apache.thrift.transport.TTransport
public int read(byte[] buf, int off, int len) throws org.apache.thrift.transport.TTransportException
read
in class org.apache.thrift.transport.TTransport
org.apache.thrift.transport.TTransportException
public int size()
public int streamTo(org.apache.thrift.transport.TNonblockingTransport transport) throws IOException
transport
- The transport to write contents into.IOException
- on any I/O related error, such as socket disconnect.public boolean isFullyStreamed()
public String toString()
public void write(byte[] buffer, int offset, int len)
count
bytes from the byte buffer buffer
starting at
offset index
to this stream.write
in class org.apache.thrift.transport.TTransport
buffer
- the buffer to be written.offset
- the initial position in buffer
to retrieve bytes.len
- the number of bytes of buffer
to write.NullPointerException
- if buffer
is null
.IndexOutOfBoundsException
- if offset < 0
or len < 0
, or if
offset + len
is greater than the length of
buffer
.Copyright © 2013–2017. All rights reserved.