pgvector.git / summary / log / commit / refs

commit    00492d7e570e004d27968169b3e7e3dbe482e42e
Author:   Andrew Kane <andrew@ankane.org>
Date:     Sun Oct 27 21:21:15 2024 +0000

    Ensure max memory fits into Size for HNSW index scans


src/hnswscan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hnswscan.c b/src/hnswscan.c index 0994d2b8..445b7ae6 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -121,6 +121,7 @@ hnswbeginscan(Relation index, int nkeys, int norderbys) { IndexScanDesc scan; HnswScanOpaque so; + double maxMemory; scan = RelationGetIndexScan(index, nkeys, norderbys); @@ -138,7 +139,9 @@ hnswbeginscan(Relation index, int nkeys, int norderbys) /* Set support functions */ HnswInitSupport(&so->support, index); - so->maxMemory = (Size) (work_mem * 1024.0 * hnsw_scan_mem_multiplier); + /* Calculate max memory */ + maxMemory = (double) work_mem * hnsw_scan_mem_multiplier * 1024.0; + so->maxMemory = Min(maxMemory, (double) SIZE_MAX); scan->opaque = so; [parent: 857d716d9e57]