DRY code for forming index value

This commit is contained in:
Andrew Kane
2024-10-09 20:50:17 -07:00
parent 3126fbdb6f
commit 57c05c59a2
4 changed files with 43 additions and 40 deletions

View File

@@ -394,6 +394,33 @@ HnswUpdateMetaPage(Relation index, int updateEntry, HnswElement entryPoint, Bloc
UnlockReleaseBuffer(buf);
}
/*
* Form index value
*/
bool
HnswFormIndexValue(Datum *out, Datum *values, bool *isnull, const HnswTypeInfo * typeInfo, FmgrInfo *normprocinfo, Oid collation)
{
/* Detoast once for all calls */
Datum value = PointerGetDatum(PG_DETOAST_DATUM(values[0]));
/* Check value */
if (typeInfo->checkValue != NULL)
typeInfo->checkValue(DatumGetPointer(value));
/* Normalize if needed */
if (normprocinfo != NULL)
{
if (!HnswCheckNorm(normprocinfo, collation, value))
return false;
value = HnswNormValue(typeInfo, collation, value);
}
*out = value;
return true;
}
/*
* Set element tuple, except for neighbor info
*/