diff --git a/src/hnsw.h b/src/hnsw.h index 8f7164b..2a2c19b 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -385,7 +385,7 @@ void HnswGetMetaPageInfo(Relation index, int *m, HnswElement * entryPoint); void *HnswAlloc(HnswAllocator * allocator, Size size); HnswElement HnswInitElement(char *base, ItemPointer tid, int m, double ml, int maxLevel, HnswAllocator * alloc); HnswElement HnswInitElementFromBlock(BlockNumber blkno, OffsetNumber offno); -void HnswInsertElement(char *base, HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, bool existing); +void HnswFindElementNeighbors(char *base, HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, bool existing); HnswCandidate *HnswEntryCandidate(char *base, HnswElement em, Datum q, Relation rel, FmgrInfo *procinfo, Oid collation, bool loadVec); void HnswUpdateMetaPage(Relation index, int updateEntry, HnswElement entryPoint, BlockNumber insertPage, ForkNumber forkNum, bool building); void HnswSetNeighborTuple(char *base, HnswNeighborTuple ntup, HnswElement e, int m); diff --git a/src/hnswbuild.c b/src/hnswbuild.c index 04ec4a3..1541815 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -472,8 +472,8 @@ InsertTupleInMemory(HnswBuildState * buildstate, HnswElement element) updateEntryPoint = entryPoint == NULL || element->level > entryPoint->level; } - /* Insert element in graph */ - HnswInsertElement(base, element, entryPoint, NULL, procinfo, collation, m, efConstruction, false); + /* Find neighbors for element */ + HnswFindElementNeighbors(base, element, entryPoint, NULL, procinfo, collation, m, efConstruction, false); /* Apply changes in memory */ ApplyChangesInMemory(procinfo, collation, element, m, efConstruction, entryPoint, buildstate, updateEntryPoint); diff --git a/src/hnswinsert.c b/src/hnswinsert.c index ceca5db..fad16d2 100644 --- a/src/hnswinsert.c +++ b/src/hnswinsert.c @@ -608,8 +608,8 @@ HnswInsertTupleOnDisk(Relation index, Datum value, Datum *values, bool *isnull, entryPoint = HnswGetEntryPoint(index); } - /* Insert element in graph */ - HnswInsertElement(base, element, entryPoint, index, procinfo, collation, m, efConstruction, false); + /* Find neighbors for the element */ + HnswFindElementNeighbors(base, element, entryPoint, index, procinfo, collation, m, efConstruction, false); /* Apply changes on disk */ ApplyChangesOnDisk(index, procinfo, collation, element, m, efConstruction, entryPoint, building); diff --git a/src/hnswutils.c b/src/hnswutils.c index 6521377..4a311d8 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -1216,7 +1216,7 @@ PrecomputeHash(char *base, HnswElement element) * Algorithm 1 from paper */ void -HnswInsertElement(char *base, HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, bool existing) +HnswFindElementNeighbors(char *base, HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, bool existing) { List *ep; List *w; diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 7bce111..f825c11 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -208,8 +208,8 @@ RepairGraphElement(HnswVacuumState * vacuumstate, HnswElement element, HnswEleme HnswInitNeighbors(NULL, element, m, NULL); element->heaptidsLength = 0; - /* Add element to graph, skipping itself */ - HnswInsertElement(NULL, element, entryPoint, index, procinfo, collation, m, efConstruction, true); + /* Find neighbors for element, skipping itself */ + HnswFindElementNeighbors(NULL, element, entryPoint, index, procinfo, collation, m, efConstruction, true); /* Update neighbor tuple */ /* Do this before getting page to minimize locking */