Created
October 3, 2013 15:37
-
-
Save codekitchen/6811880 to your computer and use it in GitHub Desktop.
convert a key to cassandra token in the style of RandomPartitioner
This file contains hidden or 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
require 'digest/md5' | |
digest = Digest::MD5.hexdigest(ARGV[0]) | |
token = digest.to_i(16) | |
token = token - (1 << bits) if (token & (1 << (bits - 1))) != 0 | |
puts token.abs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment