jldb/mdb/pfile/iterate.go

19 lines
396 B
Go
Raw Permalink Normal View History

2023-10-13 09:43:27 +00:00
package pfile
import "bytes"
func IterateAllocated(
pf *File,
idx *Index,
each func(collectionID, itemID uint64, data []byte) error,
) error {
buf := &bytes.Buffer{}
return idx.aList.Iterate(func(collectionID, itemID uint64, pages []uint64) error {
buf.Reset()
if err := pf.readData(pages[0], buf); err != nil {
return err
}
return each(collectionID, itemID, buf.Bytes())
})
}