2023-06-29 09:13:01 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
|
|
|
)
|
|
|
|
|
|
|
|
type keySpaceIterator struct {
|
|
|
|
ng *engine.StorageEngine
|
|
|
|
cur *engine.Cursor
|
|
|
|
}
|
|
|
|
|
|
|
|
func (it *keySpaceIterator) Next(ctx context.Context, batchSize uint32) ([]objectcore.AddressWithType, error) {
|
|
|
|
var prm engine.ListWithCursorPrm
|
|
|
|
prm.WithCursor(it.cur)
|
|
|
|
prm.WithCount(batchSize)
|
|
|
|
|
|
|
|
res, err := it.ng.ListWithCursor(ctx, prm)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("cannot list objects in engine: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
it.cur = res.Cursor()
|
|
|
|
return res.AddressList(), nil
|
|
|
|
}
|
2023-07-06 15:23:52 +00:00
|
|
|
|
|
|
|
func (it *keySpaceIterator) Rewind() {
|
|
|
|
it.cur = nil
|
|
|
|
}
|