jmalkin commented on code in PR #63:
URL: 
https://github.com/apache/datasketches-postgresql/pull/63#discussion_r1177475329


##########
src/theta_sketch_pg_functions.c:
##########
@@ -287,47 +343,98 @@ Datum pg_theta_union_get_result(PG_FUNCTION_ARGS) {
   if (PG_ARGISNULL(0)) PG_RETURN_NULL();
 
   if (!AggCheckCallContext(fcinfo, &aggcontext)) {
-    elog(ERROR, "theta_union_get_result called in non-aggregate context");
+    elog(ERROR, "theta_sketch_serialize_state called in non-aggregate 
context");
   }
   oldcontext = MemoryContextSwitchTo(aggcontext);
 
-  unionptr = PG_GETARG_POINTER(0);
-  sketchptr = theta_union_get_result(unionptr);
-  bytes_out = theta_sketch_serialize(sketchptr, VARHDRSZ);
-  theta_sketch_delete(sketchptr);
-  theta_union_delete(unionptr);
+  stateptr = (struct agg_state*) PG_GETARG_POINTER(0);
+  if (stateptr->type == MUTABLE_SKETCH) {
+    stateptr->ptr = theta_sketch_compact(stateptr->ptr);

Review Comment:
   "how is a compact sketch mutable?" -- had to look at 
`theta_sketch_compact()` separately but that answered it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to