pgvector.git / summary / log / commit / refs
commit 27ccb5fa7a14418337263cbb06343f0635dee96f
Author: Andrew Kane <andrew@ankane.org>
Date: Thu Aug 10 22:23:26 2023 +0000
Improved code [skip ci]
src/hnsw.h | 2 +-
src/hnswinsert.c | 2 +-
src/hnswutils.c | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/hnsw.h b/src/hnsw.h
index b6f0e63a..a5e4cdcf 100644
--- a/src/hnsw.h
+++ b/src/hnsw.h
@@ -258,7 +258,7 @@ List *HnswSearchLayer(Datum q, List *ep, int ef, int lc, Relation index, Fmgr
HnswElement HnswGetEntryPoint(Relation index);
HnswElement HnswInitElement(ItemPointer tid, int m, double ml, int maxLevel);
void HnswFreeElement(HnswElement element);
-void HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, bool vacuuming);
+void HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, bool existing);
HnswElement HnswFindDuplicate(HnswElement e);
HnswCandidate *HnswEntryCandidate(HnswElement em, Datum q, Relation rel, FmgrInfo *procinfo, Oid collation, bool loadVec);
void HnswUpdateMetaPage(Relation index, bool updateEntry, HnswElement entryPoint, BlockNumber insertPage, ForkNumber forkNum);
diff --git a/src/hnswinsert.c b/src/hnswinsert.c
index 526c8193..bd11a836 100644
--- a/src/hnswinsert.c
+++ b/src/hnswinsert.c
@@ -426,7 +426,7 @@ WriteElement(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement elem
if (entryPoint == NULL && newEntryPoint != NULL)
{
/* Try again with new entry point */
- HnswInsertElement(element, newEntryPoint, index, procinfo, collation, m, efConstruction, false);
+ HnswInsertElement(element, newEntryPoint, index, procinfo, collation, m, efConstruction, true);
UpdateNeighborPages(index, procinfo, collation, element, m);
}
else
diff --git a/src/hnswutils.c b/src/hnswutils.c
index 9e4dbdc9..f0f972bb 100644
--- a/src/hnswutils.c
+++ b/src/hnswutils.c
@@ -885,15 +885,15 @@ HnswUpdateConnection(HnswElement element, HnswCandidate * hc, int m, int lc, int
* Algorithm 1 from paper
*/
void
-HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, bool vacuuming)
+HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, bool existing)
{
List *ep = NIL;
List *w;
int level = element->level;
int entryLevel;
Datum q = PointerGetDatum(element->vec);
- BlockNumber *skipPage = vacuuming ? &element->neighborPage : NULL;
- OffsetNumber *skipOffno = vacuuming ? &element->neighborOffno : NULL;
+ BlockNumber *skipPage = existing ? &element->neighborPage : NULL;
+ OffsetNumber *skipOffno = existing ? &element->neighborOffno : NULL;
bool removeEntryPoint;
HnswCandidate *entryCandidate;
@@ -903,7 +903,7 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
entryCandidate = HnswEntryCandidate(entryPoint, q, index, procinfo, collation, true);
ep = lappend(ep, entryCandidate);
entryLevel = entryPoint->level;
- removeEntryPoint = vacuuming && list_length(entryPoint->heaptids) == 0;
+ removeEntryPoint = existing && list_length(entryPoint->heaptids) == 0;
}
else
{
[parent: 92e25e773362]