@InterfaceAudience.Private public abstract class Chunk extends Object
| Modifier and Type | Field and Description | 
|---|---|
| protected AtomicInteger | allocCountTotal number of allocations satisfied from this buffer | 
| protected ByteBuffer | dataActual underlying data | 
| private boolean | fromPool | 
| private int | id | 
| protected AtomicInteger | nextFreeOffsetOffset for the next allocation, or the sentinel value -1 which implies that the chunk is still
 uninitialized. | 
| protected static int | OOM | 
| protected int | sizeSize of chunk in bytes | 
| protected static int | UNINITIALIZED | 
| Constructor and Description | 
|---|
| Chunk(int size,
     int id)Create an uninitialized chunk. | 
| Chunk(int size,
     int id,
     boolean fromPool)Create an uninitialized chunk. | 
| Modifier and Type | Method and Description | 
|---|---|
| int | alloc(int size)Try to allocate  sizebytes from the chunk. | 
| (package private) abstract void | allocateDataBuffer() | 
| (package private) ByteBuffer | getData() | 
| (package private) int | getId() | 
| (package private) int | getNextFreeOffset() | 
| void | init()Actually claim the memory for this chunk. | 
| (package private) boolean | isFromPool() | 
| (package private) boolean | isIndexChunk() | 
| (package private) boolean | isJumbo() | 
| (package private) void | reset()Reset the offset to UNINITIALIZED before before reusing an old chunk | 
| String | toString() | 
protected ByteBuffer data
protected static final int UNINITIALIZED
protected static final int OOM
protected AtomicInteger nextFreeOffset
protected AtomicInteger allocCount
protected final int size
private final int id
private final boolean fromPool
public Chunk(int size, int id)
size - in bytesid - the chunk idpublic Chunk(int size, int id, boolean fromPool)
size - in bytesid - the chunk idfromPool - if the chunk is formed by poolint getId()
boolean isFromPool()
boolean isJumbo()
boolean isIndexChunk()
public void init()
abstract void allocateDataBuffer()
void reset()
public int alloc(int size)
size bytes from the chunk.
 If a chunk is tried to get allocated before init() call, the thread doing the allocation
 will be in busy-wait state as it will keep looping till the nextFreeOffset is set.ByteBuffer getData()
int getNextFreeOffset()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.