From db83f4faa82fdcc026e5cfc017c2e51280174897 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 24 May 2021 18:40:34 -0700 Subject: [PATCH] Reduced memory usage during index build - #7 --- CHANGELOG.md | 4 ++++ src/ivfbuild.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9522e3a..479e023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.5 (unreleased) + +- Reduced memory usage during index build + ## 0.1.4 (2021-05-09) - Fixed kmeans for inner product diff --git a/src/ivfbuild.c b/src/ivfbuild.c index b64b5f4..2755b28 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -194,7 +194,10 @@ GetNextTuple(Tuplesortstate *sortstate, TupleDesc tupdesc, TupleTableSlot *slot, ItemPointerSet(&(*itup)->t_tid, tupblk, tupoff); } else + { *list = -1; + *itup = NULL; + } } /* @@ -243,6 +246,8 @@ InsertTuples(Relation index, IvfflatBuildState * buildstate, ForkNumber forkNum) buildstate->indtuples += 1; + pfree(itup); + GetNextTuple(buildstate->sortstate, tupdesc, slot, &itup, &list); } @@ -253,6 +258,9 @@ InsertTuples(Relation index, IvfflatBuildState * buildstate, ForkNumber forkNum) /* Set the start and insert pages */ IvfflatUpdateList(index, state, buildstate->listInfo[i], insertPage, startPage, forkNum); } + + if (itup != NULL) + pfree(itup); } /*