In CRDB, we often find ourselves using this pattern to detect changes to interleaved range keys:
if hasPoint, hasRange := iter.HasPointAndRange(); hasRange {
if rangeBounds := iter.RangeBounds(); !rangeBounds.Key.Equal(rangeStart) {
rangeStart = append(rangeStart[:0], rangeBounds.Key...)
// process new range keys
These constant comparisons are expensive, and presumably Pebble has already done these comparisons during interleaving. Pebble should expose an API to signal these changes during iteration, e.g. Iterator.RangeKeysChanged().