-
Notifications
You must be signed in to change notification settings - Fork 41
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
Applied consistent hashing as a default function #131
base: master
Are you sure you want to change the base?
Conversation
…t hasher to get connection index from a key.
if idx == self.continuum.vnodes.len() { | ||
idx = 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this make the first node (index zero) more weight than others?
@coderabbitai review |
WalkthroughThe update restructures the Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- src/client.rs (5 hunks)
Additional comments: 7
src/client.rs (7)
50-65: The
Client
struct has been correctly updated to include thecontinuum
field and thehash_function
field. TheContinuum
struct andVNode
struct are also correctly defined to support consistent hashing.72-77: The
empty_hash_function
is a placeholder and should be replaced with a proper hash function to ensure a good distribution of keys across the continuum.86-133: The
Continuum
struct's methods for managing virtual nodes and searching the continuum are correctly implemented.142-147: The
get_connections_index
method correctly uses the continuum to find the connection index, ensuring that keys are distributed based on the hash.181-189: The
get_connection
method uses a comparison to check if thehash_function
is theempty_hash_function
. This is a temporary measure and should be replaced with a proper hash function to ensure consistent hashing.308-324: The
gets
method is correctly implemented to handle multiple keys by grouping them by connection index, which reduces network workloads.563-675: The tests cover the
bsearch_continuum_index
method and key distribution, which is good. Consider adding a test for theempty_hash_function
to ensure it behaves as expected until it is replaced with a proper hash function.
This is to enable consistent hashing to get a server for a key statically. There is already an issue about this raised at #33. Tests are included but I will add more if necessary. I will add features on this to fully utilize this function like decreasing and increasing the number of nodes.
Summary by CodeRabbit
New Features
Refactor
Bug Fixes