class MemoryRecords implements Records {

    @Override
    public Iterator<LogEntry> iterator() {
        if (writable) {
            // flip on a duplicate buffer for reading
            return new RecordsIterator((ByteBuffer) this.buffer.duplicate()
                                                               .flip(), false);
        } else {
            // do not need to flip for non-writable buffer
            return new RecordsIterator(this.buffer.duplicate(), false);
        }
    }

    private  MemoryRecords(ByteBuffer buffer, CompressionType type, boolean writable, int writeLimit);

}