mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 16:46:54 +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;
|
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,24 +437,21 @@ 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))
|
|
||||||
{
|
|
||||||
if (buildstate->hnswshared)
|
|
||||||
{
|
|
||||||
HnswShared *hnswshared = buildstate->hnswshared;
|
|
||||||
|
|
||||||
SpinLockAcquire(&hnswshared->mutex);
|
|
||||||
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++hnswshared->indtuples);
|
|
||||||
SpinLockRelease(&hnswshared->mutex);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++buildstate->indtuples);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
inserted = InsertTupleInMemory(index, values, tid, buildstate);
|
||||||
|
|
||||||
|
if (inserted)
|
||||||
{
|
{
|
||||||
if (InsertTupleInMemory(index, values, tid, buildstate))
|
if (buildstate->hnswshared)
|
||||||
|
{
|
||||||
|
HnswShared *hnswshared = buildstate->hnswshared;
|
||||||
|
|
||||||
|
SpinLockAcquire(&hnswshared->mutex);
|
||||||
|
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++hnswshared->indtuples);
|
||||||
|
SpinLockRelease(&hnswshared->mutex);
|
||||||
|
}
|
||||||
|
else
|
||||||
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++buildstate->indtuples);
|
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++buildstate->indtuples);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user