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 add(self, item): if add(self.sbf, item): self.unique_count += 1