mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-13 16:16:56 +08:00
Fixed repairing graph entry point
This commit is contained in:
@@ -846,15 +846,22 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
|
|||||||
HnswElement dup;
|
HnswElement dup;
|
||||||
BlockNumber *skipPage = vacuuming ? &element->neighborPage : NULL;
|
BlockNumber *skipPage = vacuuming ? &element->neighborPage : NULL;
|
||||||
OffsetNumber *skipOffno = vacuuming ? &element->neighborOffno : NULL;
|
OffsetNumber *skipOffno = vacuuming ? &element->neighborOffno : NULL;
|
||||||
|
bool removeEntryPoint;
|
||||||
|
HnswCandidate *entryCandidate;
|
||||||
|
|
||||||
/* Get entry point and level */
|
/* Get entry point and level */
|
||||||
if (entryPoint != NULL)
|
if (entryPoint != NULL)
|
||||||
{
|
{
|
||||||
ep = lappend(ep, EntryCandidate(entryPoint, q, index, procinfo, collation, true));
|
entryCandidate = EntryCandidate(entryPoint, q, index, procinfo, collation, true);
|
||||||
|
ep = lappend(ep, entryCandidate);
|
||||||
entryLevel = entryPoint->level;
|
entryLevel = entryPoint->level;
|
||||||
|
removeEntryPoint = vacuuming && list_length(entryPoint->heaptids) == 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
entryLevel = -1;
|
entryLevel = -1;
|
||||||
|
removeEntryPoint = false;
|
||||||
|
}
|
||||||
|
|
||||||
for (int lc = entryLevel; lc >= level + 1; lc--)
|
for (int lc = entryLevel; lc >= level + 1; lc--)
|
||||||
{
|
{
|
||||||
@@ -870,6 +877,8 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
|
|||||||
int lm = GetLayerM(m, lc);
|
int lm = GetLayerM(m, lc);
|
||||||
|
|
||||||
w = SearchLayer(q, ep, efConstruction, lc, index, procinfo, collation, true, skipPage, skipOffno);
|
w = SearchLayer(q, ep, efConstruction, lc, index, procinfo, collation, true, skipPage, skipOffno);
|
||||||
|
if (removeEntryPoint)
|
||||||
|
w = list_delete_ptr(w, entryCandidate);
|
||||||
newNeighbors[lc] = SelectNeighbors(w, lm, lc, procinfo, collation, NULL);
|
newNeighbors[lc] = SelectNeighbors(w, lm, lc, procinfo, collation, NULL);
|
||||||
ep = w;
|
ep = w;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ RepairGraphElement(HnswVacuumState * vacuumstate, HnswElement element)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
entryPoint = &vacuumstate->highestPoint;
|
entryPoint = &vacuumstate->highestPoint;
|
||||||
|
entryPoint->neighbors = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entryPoint = NULL;
|
entryPoint = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user