public interface

PooledByteBuffer

implements Closeable
com.facebook.common.memory.PooledByteBuffer
Known Indirect Subclasses

Class Overview

A 'pooled' byte-buffer abstraction. Represents an immutable sequence of bytes stored off the java heap.

Summary

Nested Classes
class PooledByteBuffer.ClosedException Exception indicating that the PooledByteBuffer is closed  
Public Methods
abstract void close()
Close this PooledByteBuffer and release all underlying resources
abstract ByteBuffer getByteBuffer()
Gets the underlying ByteBuffer backing this buffer if present, else null.
abstract long getNativePtr()
Gets the pointer to native memory backing this buffer if present
abstract boolean isClosed()
Check if this instance has already been closed
abstract int read(int offset, byte[] buffer, int bufferOffset, int length)
Read consecutive bytes.
abstract byte read(int offset)
Read byte at given offset
abstract int size()
Get the size of the byte buffer
[Expand]
Inherited Methods
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public Methods

public abstract void close ()

Close this PooledByteBuffer and release all underlying resources

public abstract ByteBuffer getByteBuffer ()

Gets the underlying ByteBuffer backing this buffer if present, else null.

public abstract long getNativePtr ()

Gets the pointer to native memory backing this buffer if present

Returns
  • the pointer
Throws
UnsupportedOperationException if the buffer does not have a pointer to memory

public abstract boolean isClosed ()

Check if this instance has already been closed

Returns
  • true, if the instance has been closed

public abstract int read (int offset, byte[] buffer, int bufferOffset, int length)

Read consecutive bytes.

Parameters
offset the position in the PooledByteBuffer of the first byte to read
buffer the byte array where read bytes will be copied to
bufferOffset the position within the buffer of the first copied byte
length number of bytes to copy
Returns
  • number of bytes copied

public abstract byte read (int offset)

Read byte at given offset

Returns
  • byte at given offset

public abstract int size ()

Get the size of the byte buffer

Returns
  • the size of the byte buffer