8000 Split loading neighbor TIDs into separate function [skip ci] · postgrespro/pgvector@382a25a · GitHub
[go: up one dir, main page]

Skip to content

Commit 382a25a

Browse files
committed
Split loading neighbor TIDs into separate function [skip ci]
1 parent 0b6214a commit 382a25a

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/hnswutils.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -680,18 +680,15 @@ HnswLoadUnvisitedFromMemory(char *base, HnswElement element, HnswUnvisited * unv
680680
}
681681

682682
/*
683-
* Load unvisited neighbors from disk
683+
* Load neighbor index TIDs
684684
*/
685-
static void
686-
HnswLoadUnvisitedFromDisk(HnswElement element, HnswUnvisited * unvisited, int *unvisitedLength, visited_hash * v, Relation index, int m, int lm, int lc)
685+
static bool
686+
HnswLoadNeighborTids(HnswElement element, ItemPointerData *indextids, Relation index, int m, int lm, int lc)
687687
{
688688
Buffer buf;
689689
Page page;
690690
HnswNeighborTuple ntup;
691691
int start;
692-
ItemPointerData indextids[HNSW_MAX_M * 2];
693-
694-
*unvisitedLength = 0;
695692

696693
buf = ReadBuffer(index, element->neighborPage);
697694
LockBuffer(buf, BUFFER_LOCK_SHARE);
@@ -703,14 +700,29 @@ HnswLoadUnvisitedFromDisk(HnswElement element, HnswUnvisited * unvisited, int *u
703700
if (ntup->count != (element->level + 2) * m)
704701
{
705702
UnlockReleaseBuffer(buf);
706-
return;
703+
return false;
707704
}
708705

709706
/* Copy to minimize lock time */
710707
start = (element->level - lc) * m;
711-
memcpy(&indextids, ntup->indextids + start, lm * sizeof(ItemPointerData));
708+
memcpy(indextids, ntup->indextids + start, lm * sizeof(ItemPointerData));
712709

713710
UnlockReleaseBuffer(buf);
711+
return true;
712+
}
713+
714+
/*
715+
* Load unvisited neighbors from disk
716+
*/
717+
static void
718+
HnswLoadUnvisitedFromDisk(HnswElement element, HnswUnvisited * unvisited, int *unvisitedLength, visited_hash * v, Relation index, int m, int lm, int lc)
719+
{
720+
ItemPointerData indextids[HNSW_MAX_M * 2];
721+
722+
*unvisitedLength = 0;
723+
724+
if (!HnswLoadNeighborTids(element, indextids, index, m, lm, lc))
725+
return;
714726

715727
for (int i = 0; i < lm; i++)
716728
{

0 commit comments

Comments
 (0)
0