Last active
July 21, 2019 07:52
-
-
Save onemouth/ddcbb3ee235bd2f91414c919d58387b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (m *Map) Add(nodes ...string) { | |
for _, n := range nodes { | |
for i := 0; i < m.replicas; i++ { | |
hash := int(m.hash([]byte(strconv.Itoa(i) + " " + n))) | |
m.nodes = append(m.nodes, hash) | |
m.hashMap[hash] = n | |
} | |
} | |
sort.Ints(m.nodes) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment