Bug fix in NodeHeap
When running with a large number of nodes it fails to send the store request to the k closest nodes and instead ends up sending multiple store requests to the same 4 or 5 nodes. It appears the cause is a bug in NodeHeap which allows the same node to be pushed onto the heap multiple times bumping out other legimate nodes. This pull request just adds some logic to make sure the node isn't already in the heap before pushing.
This commit is contained in:
parent
d222050025
commit
088699bfbb
@ -94,8 +94,9 @@ class NodeHeap(object):
|
|||||||
nodes = [nodes]
|
nodes = [nodes]
|
||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
distance = self.node.distanceTo(node)
|
if node.id not in [n.id for n in self]:
|
||||||
heapq.heappush(self.heap, (distance, node))
|
distance = self.node.distanceTo(node)
|
||||||
|
heapq.heappush(self.heap, (distance, node))
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return min(len(self.heap), self.maxsize)
|
return min(len(self.heap), self.maxsize)
|
||||||
|
Loading…
Reference in New Issue
Block a user