MCPcopy Create free account
hub / github.com/documentdb/documentdb / tdigest_copy

Function tdigest_copy

pg_documentdb/src/aggregation/bson_tdigest.c:1047–1073  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1045
1046
1047static tdigest_aggstate_t *
1048tdigest_copy(tdigest_aggstate_t *state)
1049{
1050 tdigest_aggstate_t *copy;
1051
1052 copy = tdigest_aggstate_allocate(state->npercentiles, state->nvalues,
1053 state->compression);
1054
1055 memcpy(copy, state, offsetof(tdigest_aggstate_t, percentiles));
1056
1057 if (state->nvalues > 0)
1058 {
1059 memcpy(copy->values, state->values,
1060 sizeof(double) * state->nvalues);
1061 }
1062
1063 if (state->npercentiles > 0)
1064 {
1065 memcpy(copy->percentiles, state->percentiles,
1066 sizeof(double) * state->npercentiles);
1067 }
1068
1069 memcpy(copy->centroids, state->centroids,
1070 state->ncentroids * sizeof(centroid_t));
1071
1072 return copy;
1073}
1074
1075
1076Datum

Callers 1

tdigest_combineFunction · 0.85

Calls 1

Tested by

no test coverage detected