mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 08:36:54 +08:00
Simplified PrintVector [skip ci]
This commit is contained in:
36
src/vector.c
36
src/vector.c
@@ -125,30 +125,6 @@ float_overflow_error(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* Print vector - useful for debugging
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
PrintVector(char *msg, Vector * vector)
|
|
||||||
{
|
|
||||||
StringInfoData buf;
|
|
||||||
int dim = vector->dim;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
initStringInfo(&buf);
|
|
||||||
|
|
||||||
appendStringInfoChar(&buf, '[');
|
|
||||||
for (i = 0; i < dim; i++)
|
|
||||||
{
|
|
||||||
if (i > 0)
|
|
||||||
appendStringInfoString(&buf, ",");
|
|
||||||
appendStringInfoString(&buf, float8out_internal(vector->x[i]));
|
|
||||||
}
|
|
||||||
appendStringInfoChar(&buf, ']');
|
|
||||||
|
|
||||||
elog(INFO, "%s = %s", msg, buf.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert textual representation to internal representation
|
* Convert textual representation to internal representation
|
||||||
*/
|
*/
|
||||||
@@ -320,6 +296,18 @@ vector_out(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_CSTRING(buf);
|
PG_RETURN_CSTRING(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print vector - useful for debugging
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
PrintVector(char *msg, Vector * vector)
|
||||||
|
{
|
||||||
|
char *out = DatumGetPointer(DirectFunctionCall1(vector_out, PointerGetDatum(vector)));
|
||||||
|
|
||||||
|
elog(INFO, "%s = %s", msg, out);
|
||||||
|
pfree(out);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert type modifier
|
* Convert type modifier
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user