MCPcopy
hub / github.com/perkeep/perkeep / ForeachInRange

Function ForeachInRange

pkg/sorted/kv.go:284–293  ·  view source on GitHub ↗

ForeachInRange runs fn for each key/value pair in kv in the range of start and end, which behave the same as kv.Find. If fn returns an error, that same error is returned from Foreach and iteration stops.

(kv KeyValue, start, end string, fn func(key, value string) error)

Source from the content-addressed store, hash-verified

282// an error, that same error is returned from Foreach and iteration
283// stops.
284func ForeachInRange(kv KeyValue, start, end string, fn func(key, value string) error) error {
285 it := kv.Find(start, end)
286 for it.Next() {
287 if err := fn(it.Key(), it.Value()); err != nil {
288 it.Close()
289 return err
290 }
291 }
292 return it.Close()
293}
294
295// CheckSizes returns ErrKeyTooLarge if key does not respect KeyMaxSize or
296// ErrValueTooLarge if value does not respect ValueMaxSize

Callers 2

TestRemoveBlobsFunction · 0.92
ForeachFunction · 0.85

Calls 5

FindMethod · 0.65
NextMethod · 0.65
KeyMethod · 0.65
ValueMethod · 0.65
CloseMethod · 0.65

Tested by 1

TestRemoveBlobsFunction · 0.74