Aggregates data into a single ByteBuffer of a specified maximum size.
The buffer automatically grows as data is written to it, up until it reaches the specified maximum size. Once the buffer is full, the aggregator will not aggregate any more bytes until its buffer is taken out, after which a new aggregate/take buffer cycle can start.
The buffers are taken from the supplied ByteBufferPool or freshly allocated if one is not supplied.
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private final ByteBufferPool | |
| private int | |
| private final boolean | |
| private final int | |
| private RetainableByteBuffer | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public | ByteBufferAggregator(ByteBufferPool
The bufferPool, boolean ByteBufferPool from which to acquire the bufferswhether to get direct buffers direct, int the starting size of the buffer startSize, int the maximum size of the buffer which must be greater than maxSize)startSizeCreates a ByteBuffer aggregator. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the aggregator's buffer is full and should be taken, false otherwisethe buffer to copy into this aggregator; its position is updated according to
the number of aggregated bytes buffer)Aggregates the given ByteBuffer. |
| private static int | |
| public int | |
| public RetainableByteBuffer | Returns: the aggregated buffer, or null if nothing has been buffered yetTakes the buffer out of the aggregator. |
| public String | |
| private void |
| _aggregatedSize | back to summary |
|---|---|
| private int _aggregatedSize | |
| _bufferPool | back to summary |
|---|---|
| private final ByteBufferPool _bufferPool | |
| _currentSize | back to summary |
|---|---|
| private int _currentSize | |
| _direct | back to summary |
|---|---|
| private final boolean _direct | |
| _maxSize | back to summary |
|---|---|
| private final int _maxSize | |
| _retainableByteBuffer | back to summary |
|---|---|
| private RetainableByteBuffer _retainableByteBuffer | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| ByteBufferAggregator | back to summary |
|---|---|
| public ByteBufferAggregator(ByteBufferPool bufferPool, boolean direct, int startSize, int maxSize) Creates a ByteBuffer aggregator.
| |
| aggregate | back to summary |
|---|---|
| public boolean aggregate(ByteBuffer buffer) Aggregates the given ByteBuffer. This copies bytes up to the specified maximum size, at which
time this method returns
| |
| ceilToNextPowerOfTwo | back to summary |
|---|---|
| private static int ceilToNextPowerOfTwo(int val) | |
| length | back to summary |
|---|---|
| public int length() Get the currently aggregated length.
| |
| takeRetainableByteBuffer | back to summary |
|---|---|
| public RetainableByteBuffer takeRetainableByteBuffer() Takes the buffer out of the aggregator. Once the buffer has been taken out,
the aggregator resets itself and a new buffer will be acquired from the pool
during the next
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| tryExpandBufferCapacity | back to summary |
|---|---|
| private void tryExpandBufferCapacity(int remaining) | |