// scanLocked is intended to be called within at least a read lock. func (in *InMem) scanLocked(start, end Key, max int64, data llrb.Tree) ([]proto.RawKeyValue, error) { var scanned []proto.RawKeyValue if bytes.Compare(start, end) >= 0 { return scanned, nil } data.DoRange(func(kv llrb.Comparable) (done bool) { if max != 0 && int64(len(scanned)) >= max { done = true return } scanned = append(scanned, kv.(proto.RawKeyValue)) return }, proto.RawKeyValue{Key: start}, proto.RawKeyValue{Key: end}) return scanned, nil }