Improved BuildCallback

This commit is contained in:
Andrew Kane
2023-12-30 18:24:03 -05:00
parent a508b120c1
commit 736576220a

View File

@@ -413,6 +413,7 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
{ {
HnswBuildState *buildstate = (HnswBuildState *) state; HnswBuildState *buildstate = (HnswBuildState *) state;
MemoryContext oldCtx; MemoryContext oldCtx;
bool inserted;
#if PG_VERSION_NUM < 130000 #if PG_VERSION_NUM < 130000
ItemPointer tid = &hup->t_self; ItemPointer tid = &hup->t_self;
@@ -436,8 +437,11 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx); oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx);
if (buildstate->flushed) if (buildstate->flushed)
{ inserted = HnswInsertTuple(index, values, isnull, tid, buildstate->heap, true);
if (HnswInsertTuple(index, values, isnull, tid, buildstate->heap, true)) else
inserted = InsertTupleInMemory(index, values, tid, buildstate);
if (inserted)
{ {
if (buildstate->hnswshared) if (buildstate->hnswshared)
{ {
@@ -450,12 +454,6 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
else else
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++buildstate->indtuples); UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++buildstate->indtuples);
} }
}
else
{
if (InsertTupleInMemory(index, values, tid, buildstate))
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++buildstate->indtuples);
}
/* Reset memory context */ /* Reset memory context */
MemoryContextSwitchTo(oldCtx); MemoryContextSwitchTo(oldCtx);