Revert "Drop unnecessary list creation from bucketer (#2360)" (#2361)

This reverts commit 6352c0c70c.
This commit is contained in:
Markus Thömmes 2021-11-25 18:21:17 +01:00 committed by GitHub
parent 6352c0c70c
commit 608fc877e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -98,7 +98,8 @@ func (bs *BucketSet) Owner(key string) string {
}
bs.mu.RLock()
defer bs.mu.RUnlock()
ret, _ := ChooseSubset(bs.buckets, 1 /*single query wanted*/, key).PopAny()
l := ChooseSubset(bs.buckets, 1 /*single query wanted*/, key)
ret := l.UnsortedList()[0]
bs.cache.Add(key, ret)
return ret
}

View File

@ -35,11 +35,11 @@ func ExampleChooseSubset_selectOne() {
tasks := sets.NewString("task1", "task2", "task3")
ret, _ := ChooseSubset(tasks, 1, "my-key1").PopAny()
fmt.Println(ret)
ret := ChooseSubset(tasks, 1, "my-key1")
fmt.Println(ret.UnsortedList()[0])
ret, _ = ChooseSubset(tasks, 1, "something/another-key").PopAny()
fmt.Println(ret)
ret = ChooseSubset(tasks, 1, "something/another-key")
fmt.Println(ret.UnsortedList()[0])
// Output: task3
// task2
}