(cumulative_splits, kv, unused_num_partitions)
Select split for an `(id, _)` tuple using a hash of `id`.
Select split for an `(id, _)` tuple using a hash of `id`.
Select split for an ( id _ ) tuple using a hash of id .
def select_split(cumulative_splits, kv, unused_num_partitions):
  """Select split for an `(id, _)` tuple using a hash of `id`."""
  key, _ = kv
  m = hashlib.md5(key.encode('utf-8'))
  r = int(m.hexdigest(), 16) / (2 ** (8 * m.digest_size))
  for i, (name, p) in enumerate(cumulative_splits):
    if r < p:
      Metrics.counter('select_split', name).inc()
      return i
  assert False
def select_split ( cumulative_splits , kv , unused_num_partitions ) : key , _ = kv m = hashlib . md5 ( key . encode ( 'utf-8' ) ) r = int ( m . hexdigest ( ) , 16 ) / ( 2 ** ( 8 * m . digest_size ) ) for i , ( name , p ) in enumerate ( cumulative_splits ) : if r < p : Metrics . counter ( 'select_split' , name ) . inc ( ) return i assert False