Class ChunkedByteBuffer

java.lang.Object
io.nosqlbench.virtdata.userlibs.streams.fillers.ChunkedByteBuffer
All Implemented Interfaces:
Iterable<ByteBuffer>

public class ChunkedByteBuffer extends Object implements Iterable<ByteBuffer>

Synopsis

This iterator breaks some rules! The intent of this iterator is to make it programmatically easy to consume raw data in ByteBuffer mode without throwing away generated data. The efficiency loss of throwing away data is variable, but two reason are used as premise for this approach: 1) generation is not free and 2) the buf size mismatch between producer and consumer could be very high, amplifying the generation cost of data.

Yet, the iterable pattern is very easy to integrate with, and so long as the user understands what this iterable does, it should make things easier by far than *not* having this helper class.

All this iterator does is wrap another iterator and cache the current ByteBuffer, re-issuing it until it is consumed fully.

Usage Patterns

This is intended to be called as an interactive data source, where another iteration controls flow.

Warnings

This class is not thread safe. Either wrap it in a ThreadLocal with appropriate initialization for concurrent use, or make sure no concurrent access occurs.