pgvector.git / summary / log / commit / refs

commit    c7fe1571ee3d746773ce6a22ed1e7921c56bec4e
Author:   Andrew Kane <andrew@ankane.org>
Date:     Mon Jan 08 02:30:51 2024 +0000

    Improved code


src/hnswbuild.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hnswbuild.c b/src/hnswbuild.c index 3a917178..476dd0a6 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -353,9 +353,12 @@ InsertTupleInMemory(Relation index, Datum *values, ItemPointer heaptid, HnswBuil /* Look for duplicate */ dup = HnswFindDuplicate(element); - /* Update neighbors if needed */ if (dup == NULL) { + /* Add element */ + slist_push_head(&buildstate->elements, &element->next); + + /* Update neighbors */ for (int lc = element->level; lc >= 0; lc--) { int lm = HnswGetLayerM(m, lc); @@ -364,14 +367,11 @@ InsertTupleInMemory(Relation index, Datum *values, ItemPointer heaptid, HnswBuil for (int i = 0; i < neighbors->length; i++) HnswUpdateConnection(element, &neighbors->items[i], lm, lc, NULL, NULL, procinfo, collation); } - } - /* Update entry point if needed */ - if (dup == NULL && (entryPoint == NULL || element->level > entryPoint->level)) - buildstate->entryPoint = element; - - if (dup == NULL) - slist_push_head(&buildstate->elements, &element->next); + /* Update entry point if needed */ + if (entryPoint == NULL || element->level > entryPoint->level) + buildstate->entryPoint = element; + } else { /* No need to free element since memory unlikely to be reallocated */ [parent: cb4c770df264]