forked from TrueCloudLab/frostfs-node
[#1642] tree: Introduce Cursor
type
* Use `Cursor` as parameter for `TreeSortedByFilename` Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
a405fb1f39
commit
a11b2d27e4
9 changed files with 40 additions and 20 deletions
|
@ -164,7 +164,7 @@ func (f *memoryForest) TreeGetMeta(_ context.Context, cid cid.ID, treeID string,
|
|||
}
|
||||
|
||||
// TreeSortedByFilename implements the Forest interface.
|
||||
func (f *memoryForest) TreeSortedByFilename(_ context.Context, cid cid.ID, treeID string, nodeIDs MultiNode, start *string, count int) ([]MultiNodeInfo, *string, error) {
|
||||
func (f *memoryForest) TreeSortedByFilename(_ context.Context, cid cid.ID, treeID string, nodeIDs MultiNode, start *Cursor, count int) ([]MultiNodeInfo, *Cursor, error) {
|
||||
fullID := cid.String() + "/" + treeID
|
||||
s, ok := f.treeMap[fullID]
|
||||
if !ok {
|
||||
|
@ -204,14 +204,14 @@ func (f *memoryForest) TreeSortedByFilename(_ context.Context, cid cid.ID, treeI
|
|||
|
||||
r := mergeNodeInfos(res)
|
||||
for i := range r {
|
||||
if start == nil || string(findAttr(r[i].Meta, AttributeFilename)) > *start {
|
||||
if start == nil || string(findAttr(r[i].Meta, AttributeFilename)) > start.GetFilename() {
|
||||
finish := min(len(res), i+count)
|
||||
last := string(findAttr(r[finish-1].Meta, AttributeFilename))
|
||||
return r[i:finish], &last, nil
|
||||
return r[i:finish], NewCursor(last), nil
|
||||
}
|
||||
}
|
||||
last := string(res[len(res)-1].Meta.GetAttr(AttributeFilename))
|
||||
return nil, &last, nil
|
||||
return nil, NewCursor(last), nil
|
||||
}
|
||||
|
||||
// TreeGetChildren implements the Forest interface.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue