mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-10 22:56:55 +08:00
Update metapage if needed for HNSW vacuum
This commit is contained in:
@@ -368,13 +368,24 @@ RepairGraph(HnswVacuumState * vacuumstate)
|
|||||||
foreach(lc2, elements)
|
foreach(lc2, elements)
|
||||||
{
|
{
|
||||||
HnswElement element = (HnswElement) lfirst(lc2);
|
HnswElement element = (HnswElement) lfirst(lc2);
|
||||||
|
HnswElement entryPoint;
|
||||||
|
|
||||||
/* Check if any neighbors point to deleted values */
|
/* Check if any neighbors point to deleted values */
|
||||||
if (!NeedsUpdated(vacuumstate, element))
|
if (!NeedsUpdated(vacuumstate, element))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Refresh entry point for each element */
|
/* Refresh entry point for each element */
|
||||||
RepairGraphElement(vacuumstate, element, HnswGetEntryPoint(index));
|
entryPoint = HnswGetEntryPoint(index);
|
||||||
|
|
||||||
|
/* Repair connections */
|
||||||
|
RepairGraphElement(vacuumstate, element, entryPoint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update metapage if needed. Should only happen if entry point
|
||||||
|
* was replaced and highest point was outdated.
|
||||||
|
*/
|
||||||
|
if (entryPoint == NULL || element->level > entryPoint->level)
|
||||||
|
HnswUpdateMetaPage(index, HNSW_UPDATE_ENTRY_GREATER, element, InvalidBlockNumber, MAIN_FORKNUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset memory context */
|
/* Reset memory context */
|
||||||
|
|||||||
Reference in New Issue
Block a user