Added inertia

This commit is contained in:
Andrew Kane
2022-02-12 21:23:53 -08:00
parent 71d2908be1
commit fa5e90585d
2 changed files with 19 additions and 1 deletions

View File

@@ -170,6 +170,10 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
}
}
#ifdef IVFFLAT_KMEANS_DEBUG
buildstate->inertia += minDistance;
#endif
/* Create a virtual tuple */
ExecClearTuple(slot);
slot->tts_values[0] = Int32GetDatum(closestCenter);
@@ -350,6 +354,10 @@ InitBuildState(IvfflatBuildState * buildstate, Relation heap, Relation index, In
/* Reuse for each tuple */
buildstate->normvec = InitVector(buildstate->dimensions);
#ifdef IVFFLAT_KMEANS_DEBUG
buildstate->inertia = 0;
#endif
}
/*
@@ -502,8 +510,14 @@ CreateEntryPages(IvfflatBuildState * buildstate, ForkNumber forkNum)
#endif
}
/* Sort and insert */
/* Sort */
tuplesort_performsort(buildstate->sortstate);
#ifdef IVFFLAT_KMEANS_DEBUG
elog(INFO, "inertia: %.3e", buildstate->inertia);
#endif
/* Insert */
InsertTuples(buildstate->index, buildstate, forkNum);
tuplesort_end(buildstate->sortstate);
}

View File

@@ -120,6 +120,10 @@ typedef struct IvfflatBuildState
ListInfo *listInfo;
Vector *normvec;
#ifdef IVFFLAT_KMEANS_DEBUG
double inertia;
#endif
/* Sampling */
BlockSamplerData bs;
ReservoirStateData rstate;