Applied consistent hashing as a default function#131
Applied consistent hashing as a default function#131nishidy wants to merge 4 commits intoaisk:masterfrom
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.
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.
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
Clientstruct has been correctly updated to include thecontinuumfield and thehash_functionfield. TheContinuumstruct andVNodestruct are also correctly defined to support consistent hashing.72-77: The
empty_hash_functionis a placeholder and should be replaced with a proper hash function to ensure a good distribution of keys across the continuum.86-133: The
Continuumstruct's methods for managing virtual nodes and searching the continuum are correctly implemented.142-147: The
get_connections_indexmethod correctly uses the continuum to find the connection index, ensuring that keys are distributed based on the hash.181-189: The
get_connectionmethod uses a comparison to check if thehash_functionis theempty_hash_function. This is a temporary measure and should be replaced with a proper hash function to ensure consistent hashing.308-324: The
getsmethod 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_indexmethod and key distribution, which is good. Consider adding a test for theempty_hash_functionto 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