mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-07 13:10:56 +08:00
Split loading neighbor TIDs into separate function [skip ci]
This commit is contained in:
@@ -680,18 +680,15 @@ HnswLoadUnvisitedFromMemory(char *base, HnswElement element, HnswUnvisited * unv
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load unvisited neighbors from disk
|
* Load neighbor index TIDs
|
||||||
*/
|
*/
|
||||||
static void
|
static bool
|
||||||
HnswLoadUnvisitedFromDisk(HnswElement element, HnswUnvisited * unvisited, int *unvisitedLength, visited_hash * v, Relation index, int m, int lm, int lc)
|
HnswLoadNeighborTids(HnswElement element, ItemPointerData *indextids, Relation index, int m, int lm, int lc)
|
||||||
{
|
{
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
Page page;
|
Page page;
|
||||||
HnswNeighborTuple ntup;
|
HnswNeighborTuple ntup;
|
||||||
int start;
|
int start;
|
||||||
ItemPointerData indextids[HNSW_MAX_M * 2];
|
|
||||||
|
|
||||||
*unvisitedLength = 0;
|
|
||||||
|
|
||||||
buf = ReadBuffer(index, element->neighborPage);
|
buf = ReadBuffer(index, element->neighborPage);
|
||||||
LockBuffer(buf, BUFFER_LOCK_SHARE);
|
LockBuffer(buf, BUFFER_LOCK_SHARE);
|
||||||
@@ -703,14 +700,29 @@ HnswLoadUnvisitedFromDisk(HnswElement element, HnswUnvisited * unvisited, int *u
|
|||||||
if (ntup->count != (element->level + 2) * m)
|
if (ntup->count != (element->level + 2) * m)
|
||||||
{
|
{
|
||||||
UnlockReleaseBuffer(buf);
|
UnlockReleaseBuffer(buf);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy to minimize lock time */
|
/* Copy to minimize lock time */
|
||||||
start = (element->level - lc) * m;
|
start = (element->level - lc) * m;
|
||||||
memcpy(&indextids, ntup->indextids + start, lm * sizeof(ItemPointerData));
|
memcpy(indextids, ntup->indextids + start, lm * sizeof(ItemPointerData));
|
||||||
|
|
||||||
UnlockReleaseBuffer(buf);
|
UnlockReleaseBuffer(buf);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load unvisited neighbors from disk
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
HnswLoadUnvisitedFromDisk(HnswElement element, HnswUnvisited * unvisited, int *unvisitedLength, visited_hash * v, Relation index, int m, int lm, int lc)
|
||||||
|
{
|
||||||
|
ItemPointerData indextids[HNSW_MAX_M * 2];
|
||||||
|
|
||||||
|
*unvisitedLength = 0;
|
||||||
|
|
||||||
|
if (!HnswLoadNeighborTids(element, indextids, index, m, lm, lc))
|
||||||
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < lm; i++)
|
for (int i = 0; i < lm; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user