From 0f238b1fa9e942d5ffba752c02929dfa573ad2c6 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 13 Aug 2023 16:17:30 -0700 Subject: [PATCH] Update neighbors when vacuuming --- src/hnsw.h | 1 + src/hnswinsert.c | 2 +- src/hnswvacuum.c | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hnsw.h b/src/hnsw.h index a3f1d0b..c9aabf6 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -268,6 +268,7 @@ void HnswSetNeighborTuple(HnswNeighborTuple ntup, HnswElement e, int m); void HnswAddHeapTid(HnswElement element, ItemPointer heaptid); void HnswInitNeighbors(HnswElement element, int m); bool HnswInsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heap_tid, Relation heapRel); +void UpdateNeighborPages(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement e, int m); void HnswLoadElement(HnswElement element, float *distance, Datum *q, Relation index, FmgrInfo *procinfo, Oid collation, bool loadVec); void HnswSetElementTuple(HnswElementTuple etup, HnswElement element); void HnswUpdateConnection(HnswElement element, HnswCandidate * hc, int m, int lc, int *updateIdx, Relation index, FmgrInfo *procinfo, Oid collation); diff --git a/src/hnswinsert.c b/src/hnswinsert.c index 2ad1900..b397941 100644 --- a/src/hnswinsert.c +++ b/src/hnswinsert.c @@ -286,7 +286,7 @@ WriteNewElementPages(Relation index, HnswElement e, int m, BlockNumber insertPag /* * Update neighbors */ -static void +void UpdateNeighborPages(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement e, int m) { for (int lc = e->level; lc >= 0; lc--) diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 2752743..e2f412d 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -253,6 +253,9 @@ RepairGraphElement(HnswVacuumState * vacuumstate, HnswElement element) MarkBufferDirty(buf); GenericXLogFinish(state); UnlockReleaseBuffer(buf); + + /* Update neighbors */ + UpdateNeighborPages(index, procinfo, collation, element, m); } /*