mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-18 18:24:31 +08:00
Improved BuildCallback
This commit is contained in:
@@ -413,6 +413,7 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
|
||||
{
|
||||
HnswBuildState *buildstate = (HnswBuildState *) state;
|
||||
MemoryContext oldCtx;
|
||||
bool inserted;
|
||||
|
||||
#if PG_VERSION_NUM < 130000
|
||||
ItemPointer tid = &hup->t_self;
|
||||
@@ -436,8 +437,11 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
|
||||
oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx);
|
||||
|
||||
if (buildstate->flushed)
|
||||
{
|
||||
if (HnswInsertTuple(index, values, isnull, tid, buildstate->heap, true))
|
||||
inserted = HnswInsertTuple(index, values, isnull, tid, buildstate->heap, true);
|
||||
else
|
||||
inserted = InsertTupleInMemory(index, values, tid, buildstate);
|
||||
|
||||
if (inserted)
|
||||
{
|
||||
if (buildstate->hnswshared)
|
||||
{
|
||||
@@ -450,12 +454,6 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
|
||||
else
|
||||
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++buildstate->indtuples);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (InsertTupleInMemory(index, values, tid, buildstate))
|
||||
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++buildstate->indtuples);
|
||||
}
|
||||
|
||||
/* Reset memory context */
|
||||
MemoryContextSwitchTo(oldCtx);
|
||||
|
||||
Reference in New Issue
Block a user