mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
redis3: list from a start name inside an earlier node
A listing from a start name that falls inside a node, rather than on a node's key, began at the next node and skipped the rest of the node that holds the start name. A paged directory listing resumes from the last name it returned, so every page after the first lost names once the directory's list had more than one node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e58ad14e30
commit
2e945fd06b
2 files changed
+22
No files matched your search
@@ -315,6 +315,11 @@ func (nl *ItemList) ListNames(startFrom string, visitNamesFn func(name string) b
|
||||
}
|
||||
if found && bytes.Compare(nextNode.Key, lookupKey) == 0 {
|
||||
prevNode = nil
|
||||
} else if found {
|
||||
// the names from startFrom up to the next node's key are in the node before it
|
||||
if prevNode, err = nl.skipList.LoadElement(nextNode.Prev); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
prevNode, err = nl.skipList.GetLargestNode()
|
||||
|
||||
@@ -53,3 +53,20 @@ func TestItemListSplitKeysTheUpperNodeByItsSmallestName(t *testing.T) {
|
||||
t.Fatalf("after deleting b: %s, want [a c]", got)
|
||||
}
|
||||
}
|
||||
|
||||
// With nodes [a b] and [c], a listing from b starts inside the first node. A
|
||||
// paged listing resumes from the last name it returned, so it skipped what
|
||||
// that node held after it.
|
||||
func TestItemListListsFromInsideAnEarlierNode(t *testing.T) {
|
||||
store, dir := newTestStore(t)
|
||||
key := store.getKey(genDirectoryListKey(string(dir)))
|
||||
for _, name := range []string{"a", "b", "c"} {
|
||||
itemListOp(t, store, key, func(nl *ItemList) error { return nl.WriteName(name) })
|
||||
}
|
||||
if got := itemListNames(t, store, key, "b"); got != "[b c]" {
|
||||
t.Fatalf("list from b: %s, want [b c]", got)
|
||||
}
|
||||
if got := itemListNames(t, store, key, "a0"); got != "[b c]" {
|
||||
t.Fatalf("list from a0: %s, want [b c]", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user