public MemoryRecords build() {
        recordOutput.close();
        writeDefaultBatchHeader();
        ByteBuffer buffer = batchOutput.buffer().duplicate();
        buffer.flip();
        buffer.position(initialPosition);
        isOpenForAppends = false;
        return MemoryRecords.readableRecords(buffer.slice());
    }
Get a list of the records appended to the batch.
@return a list of records
raft/src/main/java/org/apache/kafka/raft/internals/BatchBuilder.java