Skip to content

Instantly share code, notes, and snippets.

@harshavardhana
Last active March 3, 2020 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshavardhana/eec320db38b52559b6e893cdb749566b to your computer and use it in GitHub Desktop.
Save harshavardhana/eec320db38b52559b6e893cdb749566b to your computer and use it in GitHub Desktop.
Shows given key name and set count, what is the set index used.
#!/usr/bin/env python3
import argparse
import binascii, sys
parser = argparse.ArgumentParser(description='Set indexer')
parser.add_argument('key', metavar='KEY', type=str, help='key name for the hash index')
parser.add_argument('setcount', metavar='SET', type=int, help='total set counts')
args = parser.parse_args()
print("Hash set index: '{0}'".format(binascii.crc32(args.key) % args.setcount))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment