AlexanderSaydakov commented on code in PR #30:
URL: 
https://github.com/apache/datasketches-bigquery/pull/30#discussion_r1744377273


##########
cpc/sqlx/cpc_sketch_get_estimate.sqlx:
##########
@@ -30,13 +30,13 @@ Param seed: This is used to confirm that the given sketch 
was configured with th
 Returns: a FLOAT64 value as the cardinality estimate.
 For more details: https://datasketches.apache.org/docs/CPC/CPC.html'''
 ) AS R"""
-const default_seed = BigInt(Module.DEFAULT_SEED);
 try {
-  var sketch = Module.cpc_sketch.deserializeFromB64(sketch, seed ? 
BigInt(seed) : default_seed);
+  var sketchObject = null;
   try {
-    return sketch.getEstimate();
+    sketchObject = Module.cpc_sketch.deserializeFromB64(sketch, seed ? 
BigInt(seed) : BigInt(Module.DEFAULT_SEED));
+    return sketchObject.getEstimate();
   } finally {
-    sketch.delete();
+    if (sketchObject != null) sketchObject.delete();
   }
 } catch (e) {
   throw new Error(Module.getExceptionMessage(e));

Review Comment:
   well, perhaps in some cases the inner and outer blocks can be combined



-- 
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