def encode(keys, key_literals, value): _key = city64(value) while True: key = "%d" % _key mapping = "%s->%s" % (key, value) if not check(keys, key): # no collision add(keys, key) key_literals.add(mapping) return key else: # a possible collision if not key_literals.check(mapping): logger.warn("[collision detected]") _key += randint(0, MIL) else: return key
def on_visit(self, s, p, o, c): site_idx = city64(_part((s, p, o), self._permutation)) % self.num_sites self.site_index.append(site_idx)