diff --git a/src/hnsw/build.c b/src/hnsw/build.c index e9d68e215..3ede9488f 100644 --- a/src/hnsw/build.c +++ b/src/hnsw/build.c @@ -467,6 +467,10 @@ static void BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo, ldb_ opts.retriever = ldb_wal_index_node_retriever; opts.retriever_mut = ldb_wal_index_node_retriever_mut; + // use palloc and pfree + opts.alloc_func = palloc; + opts.free_func = pfree; + buildstate->usearch_index = usearch_init(&opts, buildstate->pq_codebook, &error); elog(INFO, "done init usearch index"); assert(error == NULL); @@ -590,6 +594,10 @@ static void BuildEmptyIndex(Relation index, IndexInfo *indexInfo, ldb_HnswBuildS assert(0 < opts.num_centroids && opts.num_centroids <= 256); } + // use palloc and pfree + opts.alloc_func = palloc; + opts.free_func = pfree; + buildstate->usearch_index = usearch_init(&opts, buildstate->pq_codebook, &error); assert(error == NULL); diff --git a/src/hnsw/insert.c b/src/hnsw/insert.c index a9927565f..b05f88099 100644 --- a/src/hnsw/insert.c +++ b/src/hnsw/insert.c @@ -133,6 +133,11 @@ bool ldb_aminsert(Relation index, assert(tmp_num_centroids == hdr->num_centroids); assert(tmp_num_subvectors == hdr->num_subvectors); } + + // use palloc and pfree + opts.alloc_func = palloc; + opts.free_func = pfree; + // todo:: do usearch init in indexInfo->ii_AmCache uidx = usearch_init(&opts, insertstate->pq_codebook, &error); if(uidx == NULL) { diff --git a/src/hnsw/scan.c b/src/hnsw/scan.c index 17bb63a3f..10a29e3b0 100644 --- a/src/hnsw/scan.c +++ b/src/hnsw/scan.c @@ -92,6 +92,10 @@ IndexScanDesc ldb_ambeginscan(Relation index, int nkeys, int norderbys) opts.expansion_add, opts.expansion_search); + // use palloc and pfree + opts.alloc_func = palloc; + opts.free_func = pfree; + scanstate->usearch_index = usearch_init(&opts, scanstate->pq_codebook, &error); if(error != NULL) elog(ERROR, "error loading index: %s", error); assert(error == NULL);