mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-30 17:51:18 +08:00
Improved UpdateMetaPage logic [skip ci]
This commit is contained in:
@@ -151,9 +151,6 @@ CreateElementPages(HnswBuildState * buildstate)
|
||||
e->offno = PageAddItem(page, (Item) element, elementsz, InvalidOffsetNumber, false, false);
|
||||
if (e->offno == InvalidOffsetNumber)
|
||||
elog(ERROR, "failed to add index item to \"%s\"", RelationGetRelationName(index));
|
||||
|
||||
if (e == buildstate->entryPoint)
|
||||
UpdateMetaPage(index, true, e, InvalidBlockNumber, forkNum);
|
||||
}
|
||||
|
||||
insertPage = BufferGetBlockNumber(buf);
|
||||
@@ -163,7 +160,7 @@ CreateElementPages(HnswBuildState * buildstate)
|
||||
GenericXLogFinish(state);
|
||||
UnlockReleaseBuffer(buf);
|
||||
|
||||
UpdateMetaPage(index, false, NULL, insertPage, forkNum);
|
||||
UpdateMetaPage(index, true, buildstate->entryPoint, insertPage, forkNum);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -876,8 +876,16 @@ UpdateMetaPage(Relation index, bool updateEntry, HnswElement entryPoint, BlockNu
|
||||
|
||||
if (updateEntry)
|
||||
{
|
||||
metap->entryBlkno = entryPoint->blkno;
|
||||
metap->entryOffno = entryPoint->offno;
|
||||
if (entryPoint == NULL)
|
||||
{
|
||||
metap->entryBlkno = InvalidBlockNumber;
|
||||
metap->entryOffno = InvalidOffsetNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
metap->entryBlkno = entryPoint->blkno;
|
||||
metap->entryOffno = entryPoint->offno;
|
||||
}
|
||||
}
|
||||
|
||||
if (BlockNumberIsValid(insertPage))
|
||||
|
||||
Reference in New Issue
Block a user