mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-15 17:16:56 +08:00
Moved indtuples to HnswGraph
This commit is contained in:
@@ -155,6 +155,7 @@ typedef struct HnswGraph
|
|||||||
long memoryUsed;
|
long memoryUsed;
|
||||||
long memoryTotal;
|
long memoryTotal;
|
||||||
bool flushed;
|
bool flushed;
|
||||||
|
double indtuples;
|
||||||
} HnswGraph;
|
} HnswGraph;
|
||||||
|
|
||||||
typedef struct HnswSpool
|
typedef struct HnswSpool
|
||||||
@@ -180,7 +181,6 @@ typedef struct HnswShared
|
|||||||
/* Mutable state */
|
/* Mutable state */
|
||||||
int nparticipantsdone;
|
int nparticipantsdone;
|
||||||
double reltuples;
|
double reltuples;
|
||||||
double indtuples;
|
|
||||||
HnswGraph graphData;
|
HnswGraph graphData;
|
||||||
|
|
||||||
#if PG_VERSION_NUM < 120000
|
#if PG_VERSION_NUM < 120000
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
|
|||||||
|
|
||||||
if (!hnswshared)
|
if (!hnswshared)
|
||||||
ereport(NOTICE,
|
ereport(NOTICE,
|
||||||
(errmsg("hnsw graph no longer fits into maintenance_work_mem after " INT64_FORMAT " tuples", (int64) buildstate->indtuples),
|
(errmsg("hnsw graph no longer fits into maintenance_work_mem after " INT64_FORMAT " tuples", (int64) graph->indtuples),
|
||||||
errdetail("Building will take significantly more time."),
|
errdetail("Building will take significantly more time."),
|
||||||
errhint("Increase maintenance_work_mem to speed up builds.")));
|
errhint("Increase maintenance_work_mem to speed up builds.")));
|
||||||
|
|
||||||
@@ -442,13 +442,12 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
|
|||||||
if (inserted)
|
if (inserted)
|
||||||
{
|
{
|
||||||
if (hnswshared)
|
if (hnswshared)
|
||||||
{
|
|
||||||
SpinLockAcquire(&hnswshared->mutex);
|
SpinLockAcquire(&hnswshared->mutex);
|
||||||
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++hnswshared->indtuples);
|
|
||||||
|
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++graph->indtuples);
|
||||||
|
|
||||||
|
if (hnswshared)
|
||||||
SpinLockRelease(&hnswshared->mutex);
|
SpinLockRelease(&hnswshared->mutex);
|
||||||
}
|
|
||||||
else
|
|
||||||
UpdateProgress(PROGRESS_CREATEIDX_TUPLES_DONE, ++buildstate->indtuples);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset memory context */
|
/* Reset memory context */
|
||||||
@@ -467,6 +466,7 @@ InitGraph(HnswGraph * graph)
|
|||||||
graph->memoryUsed = 0;
|
graph->memoryUsed = 0;
|
||||||
graph->memoryTotal = maintenance_work_mem * 1024L;
|
graph->memoryTotal = maintenance_work_mem * 1024L;
|
||||||
graph->flushed = false;
|
graph->flushed = false;
|
||||||
|
graph->indtuples = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -552,7 +552,6 @@ ParallelHeapScan(HnswBuildState * buildstate)
|
|||||||
if (hnswshared->nparticipantsdone == nparticipanttuplesorts)
|
if (hnswshared->nparticipantsdone == nparticipanttuplesorts)
|
||||||
{
|
{
|
||||||
buildstate->graph = &hnswshared->graphData;
|
buildstate->graph = &hnswshared->graphData;
|
||||||
buildstate->indtuples = hnswshared->indtuples;
|
|
||||||
reltuples = hnswshared->reltuples;
|
reltuples = hnswshared->reltuples;
|
||||||
SpinLockRelease(&hnswshared->mutex);
|
SpinLockRelease(&hnswshared->mutex);
|
||||||
break;
|
break;
|
||||||
@@ -812,7 +811,6 @@ HnswBeginParallel(HnswBuildState * buildstate, bool isconcurrent, int request)
|
|||||||
/* Initialize mutable state */
|
/* Initialize mutable state */
|
||||||
hnswshared->nparticipantsdone = 0;
|
hnswshared->nparticipantsdone = 0;
|
||||||
hnswshared->reltuples = 0;
|
hnswshared->reltuples = 0;
|
||||||
hnswshared->indtuples = 0;
|
|
||||||
InitGraph(&hnswshared->graphData);
|
InitGraph(&hnswshared->graphData);
|
||||||
/* TODO Support in-memory builds */
|
/* TODO Support in-memory builds */
|
||||||
hnswshared->graphData.memoryTotal = 0;
|
hnswshared->graphData.memoryTotal = 0;
|
||||||
@@ -920,6 +918,8 @@ BuildGraph(HnswBuildState * buildstate, ForkNumber forkNum)
|
|||||||
true, BuildCallback, (void *) buildstate, NULL);
|
true, BuildCallback, (void *) buildstate, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildstate->indtuples = buildstate->graph->indtuples;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush pages */
|
/* Flush pages */
|
||||||
|
|||||||
Reference in New Issue
Block a user