Added bulk hashing [skip ci]

This commit is contained in:
Andrew Kane
2024-10-29 11:41:57 -07:00
parent e3e74fe94e
commit ec68b75892

View File

@@ -722,6 +722,8 @@ CountElement(HnswElement skipElement, HnswElement e)
static void
HnswLoadUnvisitedFromMemory(char *base, HnswElement element, HnswUnvisited * unvisited, int *unvisitedLength, visited_hash * v, int lc, HnswNeighborArray * localNeighborhood, Size neighborhoodSize)
{
uint32 hashes[HNSW_MAX_M * 2];
/* Get the neighborhood at layer lc */
HnswNeighborArray *neighborhood = HnswGetNeighbors(base, element, lc);
@@ -732,16 +734,35 @@ HnswLoadUnvisitedFromMemory(char *base, HnswElement element, HnswUnvisited * unv
*unvisitedLength = 0;
for (int i = 0; i < localNeighborhood->length; i++)
hashes[i] = HnswPtrAccess(base, localNeighborhood->items[i].element)->hash;
if (base != NULL)
{
for (int i = 0; i < localNeighborhood->length; i++)
{
HnswCandidate *hc = &localNeighborhood->items[i];
bool found;
AddToVisited(base, v, hc->element, true, &found);
offsethash_insert_hash(v->offsets, HnswPtrOffset(hc->element), hashes[i], &found);
if (!found)
unvisited[(*unvisitedLength)++].element = HnswPtrAccess(base, hc->element);
}
}
else
{
for (int i = 0; i < localNeighborhood->length; i++)
{
HnswCandidate *hc = &localNeighborhood->items[i];
bool found;
pointerhash_insert_hash(v->pointers, (uintptr_t) HnswPtrPointer(hc->element), hashes[i], &found);
if (!found)
unvisited[(*unvisitedLength)++].element = HnswPtrAccess(base, hc->element);
}
}
}
/*