fork(4) download
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. def easyHash(s):
  5. """
  6. MDSD used the following hash algorithm to cal a first part of partition key
  7. """
  8. strHash = 0
  9. multiplier = 37
  10. for c in s:
  11. strHash = strHash * multiplier + ord(c)
  12. #Only keep the last 64bit, since the mod base is 100
  13. strHash = strHash % (1<<64)
  14. return strHash % 100 #Assume eventVolume is Large
  15.  
  16. print easyHash(u"àèìòù Hello world! Hello world! Hello world! Hello world! Hello world! Hello world! Hello world!");
Success #stdin #stdout 0.01s 7692KB
stdin
Standard input is empty
stdout
58