This is an automated email from the ASF dual-hosted git repository. alsay pushed a commit to branch shadowing in repository https://gitbox.apache.org/repos/asf/datasketches-bigquery.git
commit cd30a433454edfb409831f72d7254864c100e0ce Author: AlexanderSaydakov <[email protected]> AuthorDate: Tue Sep 3 16:18:43 2024 -0700 avoid shadowing, other cleanup --- cpc/sqlx/cpc_sketch_get_estimate.sqlx | 8 ++++---- cpc/sqlx/cpc_sketch_get_estimate_and_bounds.sqlx | 8 ++++---- cpc/sqlx/cpc_sketch_scalar_union.sqlx | 5 +++-- cpc/sqlx/cpc_sketch_to_string.sqlx | 7 ++++--- kll/sqlx/kll_sketch_float_get_n.sqlx | 7 ++++--- kll/sqlx/kll_sketch_float_get_quantile.sqlx | 9 +++++---- kll/sqlx/kll_sketch_float_get_rank.sqlx | 9 +++++---- kll/sqlx/kll_sketch_float_to_string.sqlx | 7 ++++--- theta/sqlx/theta_sketch_a_not_b.sqlx | 5 +++-- theta/sqlx/theta_sketch_get_estimate.sqlx | 7 ++++--- theta/sqlx/theta_sketch_get_estimate_and_bounds.sqlx | 7 ++++--- theta/sqlx/theta_sketch_to_string.sqlx | 7 ++++--- 12 files changed, 48 insertions(+), 38 deletions(-) diff --git a/cpc/sqlx/cpc_sketch_get_estimate.sqlx b/cpc/sqlx/cpc_sketch_get_estimate.sqlx index c736da5..ad8273d 100644 --- a/cpc/sqlx/cpc_sketch_get_estimate.sqlx +++ b/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)); diff --git a/cpc/sqlx/cpc_sketch_get_estimate_and_bounds.sqlx b/cpc/sqlx/cpc_sketch_get_estimate_and_bounds.sqlx index 7795580..56e85a5 100644 --- a/cpc/sqlx/cpc_sketch_get_estimate_and_bounds.sqlx +++ b/cpc/sqlx/cpc_sketch_get_estimate_and_bounds.sqlx @@ -33,13 +33,13 @@ Param seed: This is used to confirm that the given sketch was configured with th Returns: an array of 3 FLOAT64 values as {estimate, lowerBound, upperBound}. 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(), sketch.getLowerBound(num_std_devs), sketch.getUpperBound(num_std_devs)]; + sketchObject = Module.cpc_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : BigInt(Module.DEFAULT_SEED)); + return [sketchObject.getEstimate(), sketchObject.getLowerBound(num_std_devs), sketchObject.getUpperBound(num_std_devs)]; } finally { - sketch.delete(); + if (sketchObject != null) sketchObject.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/cpc/sqlx/cpc_sketch_scalar_union.sqlx b/cpc/sqlx/cpc_sketch_scalar_union.sqlx index 7e736f9..782dbf6 100644 --- a/cpc/sqlx/cpc_sketch_scalar_union.sqlx +++ b/cpc/sqlx/cpc_sketch_scalar_union.sqlx @@ -35,13 +35,14 @@ For more details: https://datasketches.apache.org/docs/CPC/CPC.html''' const default_lg_k = 12; const default_seed = BigInt(Module.DEFAULT_SEED); try { - var union = new Module.cpc_union(lg_k ? lg_k : default_lg_k, seed ? BigInt(seed) : default_seed); + var union = null; try { + union = new Module.cpc_union(lg_k ? lg_k : default_lg_k, seed ? BigInt(seed) : default_seed); union.updateWithB64(sketchA, seed ? BigInt(seed) : default_seed) union.updateWithB64(sketchB, seed ? BigInt(seed) : default_seed) return union.getResultB64(); } finally { - union.delete(); + if (union != null) union.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/cpc/sqlx/cpc_sketch_to_string.sqlx b/cpc/sqlx/cpc_sketch_to_string.sqlx index b11ffed..91d9a4f 100644 --- a/cpc/sqlx/cpc_sketch_to_string.sqlx +++ b/cpc/sqlx/cpc_sketch_to_string.sqlx @@ -32,11 +32,12 @@ 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.toString(); + sketchObject = Module.cpc_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed); + return sketchObject.toString(); } finally { - sketch.delete(); + if (sketchObject != null) sketchObject.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/kll/sqlx/kll_sketch_float_get_n.sqlx b/kll/sqlx/kll_sketch_float_get_n.sqlx index 618be2c..7c127de 100644 --- a/kll/sqlx/kll_sketch_float_get_n.sqlx +++ b/kll/sqlx/kll_sketch_float_get_n.sqlx @@ -30,11 +30,12 @@ Returns: stream length For more details: https://datasketches.apache.org/docs/KLL/KLLSketch.html''' ) AS R""" try { - var sketch = Module.kll_sketch_float.deserializeFromB64(sketch); + var sketchObject = null; try { - return sketch.getN(); + sketchObject = Module.kll_sketch_float.deserializeFromB64(sketch); + return sketchObject.getN(); } finally { - sketch.delete(); + if (sketchObject != null) sketchObject.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/kll/sqlx/kll_sketch_float_get_quantile.sqlx b/kll/sqlx/kll_sketch_float_get_quantile.sqlx index b4e8d2e..54727f2 100644 --- a/kll/sqlx/kll_sketch_float_get_quantile.sqlx +++ b/kll/sqlx/kll_sketch_float_get_quantile.sqlx @@ -32,12 +32,13 @@ Returns: an approximate quantile associated with the given rank. For more details: https://datasketches.apache.org/docs/KLL/KLLSketch.html''' ) AS R""" try { - var sketch = Module.kll_sketch_float.deserializeFromB64(sketch); + var sketchObject = null; try { - if (sketch.isEmpty()) return null; - return sketch.getQuantile(rank, inclusive); + sketchObject = Module.kll_sketch_float.deserializeFromB64(sketch); + if (sketchObject.isEmpty()) return null; + return sketchObject.getQuantile(rank, inclusive); } finally { - sketch.delete(); + if (sketchObject != null) sketchObject.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/kll/sqlx/kll_sketch_float_get_rank.sqlx b/kll/sqlx/kll_sketch_float_get_rank.sqlx index 3b245b7..9983dea 100644 --- a/kll/sqlx/kll_sketch_float_get_rank.sqlx +++ b/kll/sqlx/kll_sketch_float_get_rank.sqlx @@ -32,12 +32,13 @@ Returns: an approximate rank of the given value. For more details: https://datasketches.apache.org/docs/KLL/KLLSketch.html''' ) AS R""" try { - var sketch = Module.kll_sketch_float.deserializeFromB64(sketch); + var sketchObject = null; try { - if (sketch.isEmpty()) return null; - return sketch.getRank(value, inclusive); + sketchObject = Module.kll_sketch_float.deserializeFromB64(sketch); + if (sketchObject.isEmpty()) return null; + return sketchObject.getRank(value, inclusive); } finally { - sketch.delete(); + if (sketchObject != null) sketchObject.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/kll/sqlx/kll_sketch_float_to_string.sqlx b/kll/sqlx/kll_sketch_float_to_string.sqlx index 052c641..5539540 100644 --- a/kll/sqlx/kll_sketch_float_to_string.sqlx +++ b/kll/sqlx/kll_sketch_float_to_string.sqlx @@ -30,11 +30,12 @@ Returns: a string that represents the state of the given sketch. For more details: https://datasketches.apache.org/docs/KLL/KLLSketch.html''' ) AS R""" try { - var sketch = Module.kll_sketch_float.deserializeFromB64(sketch); + var sketchObject = null; try { - return sketch.toString(); + sketchObject = Module.kll_sketch_float.deserializeFromB64(sketch); + return sketchObject.toString(); } finally { - sketch.delete(); + if (sketchObject != null) sketchObject.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/theta/sqlx/theta_sketch_a_not_b.sqlx b/theta/sqlx/theta_sketch_a_not_b.sqlx index 2f50067..d16b91a 100644 --- a/theta/sqlx/theta_sketch_a_not_b.sqlx +++ b/theta/sqlx/theta_sketch_a_not_b.sqlx @@ -33,11 +33,12 @@ For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramewor ) AS R""" const default_seed = BigInt(Module.DEFAULT_SEED); try { - var a_not_b = new Module.theta_a_not_b(seed ? BigInt(seed) : default_seed); + var a_not_b = null; try { + a_not_b = new Module.theta_a_not_b(seed ? BigInt(seed) : default_seed); return a_not_b.computeWithB64ReturnB64Compressed(sketchA, sketchB, seed ? BigInt(seed) : default_seed); } finally { - a_not_b.delete(); + if (a_not_b != null) a_not_b.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/theta/sqlx/theta_sketch_get_estimate.sqlx b/theta/sqlx/theta_sketch_get_estimate.sqlx index 4afeb20..d37e6e7 100644 --- a/theta/sqlx/theta_sketch_get_estimate.sqlx +++ b/theta/sqlx/theta_sketch_get_estimate.sqlx @@ -32,11 +32,12 @@ For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramewor ) AS R""" const default_seed = BigInt(Module.DEFAULT_SEED); try { - var sketch = Module.compact_theta_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed); + var sketchObject = null; try { - return sketch.getEstimate(); + sketchObject = Module.compact_theta_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed); + return sketchObject.getEstimate(); } finally { - sketch.delete(); + if (sketchObject != null) sketchObject.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/theta/sqlx/theta_sketch_get_estimate_and_bounds.sqlx b/theta/sqlx/theta_sketch_get_estimate_and_bounds.sqlx index 0ab9e0d..1f80b4f 100644 --- a/theta/sqlx/theta_sketch_get_estimate_and_bounds.sqlx +++ b/theta/sqlx/theta_sketch_get_estimate_and_bounds.sqlx @@ -35,11 +35,12 @@ For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramewor ) AS R""" const default_seed = BigInt(Module.DEFAULT_SEED); try { - var sketch = Module.compact_theta_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed); + var sketchObject = null; try { - return [sketch.getEstimate(), sketch.getLowerBound(num_std_devs), sketch.getUpperBound(num_std_devs)]; + sketchObject = Module.compact_theta_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed); + return [sketchObject.getEstimate(), sketchObject.getLowerBound(num_std_devs), sketchObject.getUpperBound(num_std_devs)]; } finally { - sketch.delete(); + if (sketchObject != null) sketchObject.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); diff --git a/theta/sqlx/theta_sketch_to_string.sqlx b/theta/sqlx/theta_sketch_to_string.sqlx index 57eecd1..180cbf2 100644 --- a/theta/sqlx/theta_sketch_to_string.sqlx +++ b/theta/sqlx/theta_sketch_to_string.sqlx @@ -32,11 +32,12 @@ For more details: https://datasketches.apache.org/docs/Theta/ThetaSketchFramewor ) AS R""" const default_seed = BigInt(Module.DEFAULT_SEED); try { - var sketch = Module.compact_theta_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed); + var sketchObject = null; try { - return sketch.toString(); + sketchObject = Module.compact_theta_sketch.deserializeFromB64(sketch, seed ? BigInt(seed) : default_seed); + return sketchObject.toString(); } finally { - sketch.delete(); + if (sketchObject != null) sketchObject.delete(); } } catch (e) { throw new Error(Module.getExceptionMessage(e)); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
