From abbc1c33791f28ee1d0eafef3c0bc97180e282ab Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 11 Mar 2024 17:30:27 -0700 Subject: [PATCH] Improved code --- src/hnswbuild.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hnswbuild.c b/src/hnswbuild.c index b0f00d1..ebc9f44 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -400,7 +400,7 @@ UpdateNeighborsInMemory(char *base, FmgrInfo *procinfo, Oid collation, HnswEleme * Update graph in memory */ static void -UpdateGraphInMemory(FmgrInfo *procinfo, Oid collation, HnswElement element, int m, int efConstruction, HnswElement entryPoint, HnswBuildState * buildstate) +UpdateGraphInMemory(FmgrInfo *procinfo, Oid collation, HnswElement element, int m, int efConstruction, bool updateEntryPoint, HnswBuildState * buildstate) { HnswGraph *graph = buildstate->graph; char *base = buildstate->hnswarea; @@ -416,7 +416,7 @@ UpdateGraphInMemory(FmgrInfo *procinfo, Oid collation, HnswElement element, int UpdateNeighborsInMemory(base, procinfo, collation, element, m); /* Update entry point if needed (already have lock) */ - if (entryPoint == NULL || element->level > entryPoint->level) + if (updateEntryPoint) HnswPtrStore(base, graph->entryPoint, element); } @@ -452,7 +452,7 @@ InsertTupleInMemory(HnswBuildState * buildstate, HnswElement element) HnswFindElementNeighbors(base, element, entryPoint, NULL, procinfo, collation, m, efConstruction, false); /* Update graph in memory */ - UpdateGraphInMemory(procinfo, collation, element, m, efConstruction, entryPoint, buildstate); + UpdateGraphInMemory(procinfo, collation, element, m, efConstruction, updateEntryPoint, buildstate); /* Release entry lock */ if (updateEntryPoint)