Reads in an LSM engine are streams, not single lookups - you walk keys in order across memory and many files. Today you introduce the Iterator, one cursor abstraction the memtable and every future SSTable will share.
Expose an iterator that walks the memtable's entries in ascending key order.
Every read path in an LSM engine is a merge of sorted cursors: the memtable’s
entries, plus one cursor per on-disk file, walked together in key order. So the
cursor itself needs to be an abstraction, not a memtable-specific loop. Today’s
Iterator - Valid, Key, Value, Next - is that shared shape.
Because the memtable already stores entries sorted, its iterator is trivial: a position that starts at the first entry and advances one at a time, becoming invalid when it runs off the end. Defining the interface now, with the simplest possible implementor, means the SSTable reader and the merge iterator you build later all speak the same language and snap together without adapters.
// one cursor shape the whole engine reusestype Iterator interface {Valid() bool // is the cursor on a live entry?Key() stringValue() []byteNext() // advance one entry}// the memtable's iterator is just an index into the sorted slice