go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

Support range deletion in batch

Open rjl493456442 opened this issue 6 months ago • 0 comments

Pebble supports range deletion in both database level and batch level

// DeleteRange deletes all of the point keys (and values) in the range
// [start,end) (inclusive on start, exclusive on end). DeleteRange does NOT
// delete overlapping range keys (eg, keys set via RangeKeySet).
//
// It is safe to modify the contents of the arguments after DeleteRange
// returns.
func (b *Batch) DeleteRange(start, end []byte, _ *WriteOptions) error {
	deferredOp := b.DeleteRangeDeferred(len(start), len(end))
	copy(deferredOp.Key, start)
	copy(deferredOp.Value, end)
	// TODO(peter): Manually inline DeferredBatchOp.Finish(). Mid-stack inlining
	// in go1.13 will remove the need for this.
	if deferredOp.index != nil {
		if err := deferredOp.index.Add(deferredOp.offset); err != nil {
			return err
		}
	}
	return nil
}

Now, the range deletion is only available at database level, loosing the complexity in case some additional data needs to be removed atomically with the data range.

Feature request: implement range deletion in batch as well.

rjl493456442 avatar Jun 02 '25 06:06 rjl493456442