8000 Improved HnswUpdateConnection parameters [skip ci] · postgrespro/pgvector@525e3b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 525e3b8

Browse files
committed
Improved HnswUpdateConnection parameters [skip ci]
1 parent 8eb8cdf commit 525e3b8

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/hnsw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void HnswUpdateNeighborsOnDisk(Relation index, FmgrInfo *procinfo, Oid collatio
393393
void HnswLoadElementFromTuple(HnswElement element, HnswElementTuple etup, bool loadHeaptids, bool loadVec);
394394
void HnswLoadElement(HnswElement element, double *distance, Datum *q, Relation index, FmgrInfo *procinfo, Oid collation, bool loadVec, double *maxDistance);
395395
void HnswSetElementTuple(char *base, HnswElementTuple etup, HnswElement element);
396-
void HnswUpdateConnection(char *base, HnswElement element, HnswCandidate * hc, HnswNeighborArray * neighbors, int lm, int *updateIdx, Relation index, FmgrInfo *procinfo, Oid collation);
396+
void HnswUpdateConnection(char *base, HnswNeighborArray * neighbors, HnswElement newElement, float distance, int lm, int *updateIdx, Relation index, FmgrInfo *procinfo, Oid collation);
397397
bool HnswLoadNeighborTids(HnswElement element, ItemPointerData *indextids, Relation index, int m, int lm, int lc);
398398
void HnswInitLockTranche(void);
399399
const HnswTypeInfo *HnswGetTypeInfo(Relation index);

src/hnswbuild.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ UpdateNeighborsInMemory(char *base, FmgrInfo *procinfo, Oid collation, HnswEleme
388388
Assert(neighborElement);
389389

390390
LWLockAcquire(&neighborElement->lock, LW_EXCLUSIVE);
391-
HnswUpdateConnection(base, e, hc, HnswGetNeighbors(base, neighborElement, lc), lm, NULL, NULL, procinfo, collation);
391+
HnswUpdateConnection(base, HnswGetNeighbors(base, neighborElement, lc), e, hc->distance, lm, NULL, NULL, procinfo, collation);
392392
LWLockRelease(&neighborElement->lock);
393393
}
394394
}

src/hnswinsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ HnswUpdateNeighborsOnDisk(Relation index, FmgrInfo *procinfo, Oid collation, Hns
461461
LoadElementsForInsert(neighborNeighbors, q, &idx, index, procinfo, collation);
462462

463463
if (idx == -1)
464-
HnswUpdateConnection(base, e, hc, neighborNeighbors, lm, &idx, index, procinfo, collation);
464+
HnswUpdateConnection(base, neighborNeighbors, e, hc->distance, lm, &idx, index, procinfo, collation);
465465
}
466466

467467
/* New element was not selected as a neighbor */

src/hnswutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,12 +1078,12 @@ AddConnections(char *base, HnswElement element, List *neighbors, int lc)
10781078
* Update connections
10791079
*/
10801080
void
1081-
HnswUpdateConnection(char *base, HnswElement newElement, HnswCandidate * hc, HnswNeighborArray * neighbors, int lm, int *updateIdx, Relation index, FmgrInfo *procinfo, Oid collation)
1081+
HnswUpdateConnection(char *base, HnswNeighborArray * neighbors, HnswElement newElement, float distance, int lm, int *updateIdx, Relation index, FmgrInfo *procinfo, Oid collation)
10821082
{
10831083
HnswCandidate newHc;
10841084

10851085
HnswPtrStore(base, newHc.element, newElement);
1086-
newHc.distance = hc->distance;
1086+
newHc.distance = distance;
10871087

10881088
if (neighbors->length < lm)
10891089
{

0 commit comments

Comments
 (0)
0