I need advice how to aproach this task. The autor has created function find_next_free_dataset_num(node) and it searching for free slots in distributed hash table. This DHT uses dictionary like interface which override __setitem__, __getitem__ and __contains__. Which is good design. But this function uses linear probing now for searching new unused slot for predictable key. So the question is if exponential num = num*num + 1 solves it and how to implement binary search on new num value between 0 and used slot num?
def predictable_key(node, num):
return "monitor_dataset_{0}_{1}".format(node.get_address(), str(num))
def find_next_free_dataset_num(node):
# FIXME probe with exponential increase then binary search lowest unused
num = 0
while node[predictable_key(node, num)] is not None:
_log.info("Dataset {0} already exists!".format(num))
num += 1
return num