Search in sources :

Example 1 with DefaultRecordBatch

use of org.apache.kafka.common.record.DefaultRecordBatch in project kafka by apache.

the class RecordsIterator method nextBatch.

private Optional<Batch<T>> nextBatch() {
    if (!nextBatches.hasNext()) {
        nextBatches = nextBatches();
    }
    if (nextBatches.hasNext()) {
        MutableRecordBatch nextBatch = nextBatches.next();
        // Update the buffer position to reflect the read batch
        allocatedBuffer.ifPresent(buffer -> buffer.position(buffer.position() + nextBatch.sizeInBytes()));
        if (!(nextBatch instanceof DefaultRecordBatch)) {
            throw new IllegalStateException(String.format("DefaultRecordBatch expected by record type was %s", nextBatch.getClass()));
        }
        return Optional.of(readBatch((DefaultRecordBatch) nextBatch));
    }
    return Optional.empty();
}
Also used : DefaultRecordBatch(org.apache.kafka.common.record.DefaultRecordBatch) MutableRecordBatch(org.apache.kafka.common.record.MutableRecordBatch)

Aggregations

DefaultRecordBatch (org.apache.kafka.common.record.DefaultRecordBatch)1 MutableRecordBatch (org.apache.kafka.common.record.MutableRecordBatch)1