Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wrapping around to key_to_nodes #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ruslandoga
Copy link

@ruslandoga ruslandoga commented Feb 10, 2025

👋

This is a possible fix for #39

@ruslandoga
Copy link
Author

ruslandoga commented Feb 10, 2025

Kindly pinging @Gazler as well :)
(as the original contributor of key_to_nodes)

@@ -246,27 +246,32 @@ defmodule HashRing do

case :gb_trees.iterator_from(hash, r) |> :gb_trees.next() do
{_key, node, iter} ->
find_nodes_from_iter(iter, count - 1, [node])
find_nodes_from_iter(r, iter, count - 1, [node], _restarted? = false)
Copy link
Author

@ruslandoga ruslandoga Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if restarted? is needed, but I added it to be safe.


On second though, if we count = min(length(nodes), count) it's not needed.

results
:none ->
if restarted? do
Enum.reverse(results)
Copy link
Author

@ruslandoga ruslandoga Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

results were not reversed originally, but I think they need to be since the "happy path" does it (on line 257).

@ruslandoga ruslandoga changed the title add wrapping over to key_to_nodes add wrapping around to key_to_nodes Feb 10, 2025
@ruslandoga ruslandoga changed the title add wrapping around to key_to_nodes Add wrapping around to key_to_nodes Feb 10, 2025
@ruslandoga ruslandoga changed the title Add wrapping around to key_to_nodes Add wrapping around to key_to_nodes Feb 10, 2025
anas-ksibi added a commit to enreach-labs/libring that referenced this pull request Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant