175 WindowObject winobj = PG_WINDOW_OBJECT();
177 int64 curpos, rowcount;
179 rowcount = WinGetPartitionRowCount(winobj);
181 WinGetPartitionLocalMemory(winobj,
192 k = DatumGetInt32(WinGetFuncArgCurrent(winobj, 1, &isnull));
193 if (isnull || k <= 0)
201 N = (int) WinGetPartitionRowCount(winobj);
212 lwpgerror(
"K (%d) must be smaller than the number of rows in the group (%d)", k, N);
216 geoms = palloc(
sizeof(
LWGEOM*) * N);
217 for (i = 0; i < N; i++)
220 Datum arg = WinGetFuncArgInPartition(winobj, 0, i,
221 WINDOW_SEEK_HEAD,
false, &isnull, &isout);
238 for (i = 0; i < N; i++)
252 memcpy(context->
result,
r,
sizeof(
int) * N);
260 curpos = WinGetCurrentPosition(winobj);
261 PG_RETURN_INT32(context->
result[curpos]);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
int * lwgeom_cluster_2d_kmeans(const LWGEOM **geoms, uint32_t ngeoms, uint32_t k)
Take a list of LWGEOMs and a number of clusters and return an integer array indicating which cluster ...