Skip to content

db: iterator API to cheaply detect changes to range keys #1775

@erikgrinaker

Description

@erikgrinaker

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().

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions