mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-12 07:36:55 +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);
|
e->offno = PageAddItem(page, (Item) element, elementsz, InvalidOffsetNumber, false, false);
|
||||||
if (e->offno == InvalidOffsetNumber)
|
if (e->offno == InvalidOffsetNumber)
|
||||||
elog(ERROR, "failed to add index item to \"%s\"", RelationGetRelationName(index));
|
elog(ERROR, "failed to add index item to \"%s\"", RelationGetRelationName(index));
|
||||||
|
|
||||||
if (e == buildstate->entryPoint)
|
|
||||||
UpdateMetaPage(index, true, e, InvalidBlockNumber, forkNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
insertPage = BufferGetBlockNumber(buf);
|
insertPage = BufferGetBlockNumber(buf);
|
||||||
@@ -163,7 +160,7 @@ CreateElementPages(HnswBuildState * buildstate)
|
|||||||
GenericXLogFinish(state);
|
GenericXLogFinish(state);
|
||||||
UnlockReleaseBuffer(buf);
|
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)
|
if (updateEntry)
|
||||||
{
|
{
|
||||||
metap->entryBlkno = entryPoint->blkno;
|
if (entryPoint == NULL)
|
||||||
metap->entryOffno = entryPoint->offno;
|
{
|
||||||
|
metap->entryBlkno = InvalidBlockNumber;
|
||||||
|
metap->entryOffno = InvalidOffsetNumber;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
metap->entryBlkno = entryPoint->blkno;
|
||||||
|
metap->entryOffno = entryPoint->offno;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BlockNumberIsValid(insertPage))
|
if (BlockNumberIsValid(insertPage))
|
||||||
|
|||||||
Reference in New Issue
Block a user