You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2022/06/17 22:49:26 UTC

[datasketches-postgresql] 01/01: comply with standard C

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch kll_double
in repository https://gitbox.apache.org/repos/asf/datasketches-postgresql.git

commit 0dc342ce63c2216527cb4c2046b781506ab5741b
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Fri Jun 17 15:48:50 2022 -0700

    comply with standard C
---
 src/kll_double_sketch_pg_functions.c | 12 ++++++++----
 src/kll_float_sketch_pg_functions.c  | 12 ++++++++----
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/kll_double_sketch_pg_functions.c b/src/kll_double_sketch_pg_functions.c
index b1d9616..4810839 100644
--- a/src/kll_double_sketch_pg_functions.c
+++ b/src/kll_double_sketch_pg_functions.c
@@ -353,6 +353,10 @@ Datum pg_kll_double_sketch_get_histogram(PG_FUNCTION_ARGS) {
   char elmalign_out;
   int arr_len_out;
 
+  double* split_points;
+  double min_value;
+  double max_value;
+  double delta;
   int i;
 
   bytes_in = PG_GETARG_BYTEA_P(0);
@@ -363,10 +367,10 @@ Datum pg_kll_double_sketch_get_histogram(PG_FUNCTION_ARGS) {
     elog(ERROR, "at least two bins expected");
   }
 
-  double* split_points = palloc(sizeof(double) * (num_bins - 1));
-  const double min_value = kll_double_sketch_get_quantile(sketchptr, 0);
-  const double max_value = kll_double_sketch_get_quantile(sketchptr, 1);
-  const double delta = (max_value - min_value) / num_bins;
+  split_points = palloc(sizeof(double) * (num_bins - 1));
+  min_value = kll_double_sketch_get_quantile(sketchptr, 0);
+  max_value = kll_double_sketch_get_quantile(sketchptr, 1);
+  delta = (max_value - min_value) / num_bins;
   for (i = 0; i < num_bins - 1; i++) {
     split_points[i] = min_value + delta * (i + 1);
   }
diff --git a/src/kll_float_sketch_pg_functions.c b/src/kll_float_sketch_pg_functions.c
index e38f7aa..308b91b 100644
--- a/src/kll_float_sketch_pg_functions.c
+++ b/src/kll_float_sketch_pg_functions.c
@@ -353,6 +353,10 @@ Datum pg_kll_float_sketch_get_histogram(PG_FUNCTION_ARGS) {
   char elmalign_out;
   int arr_len_out;
 
+  float* split_points;
+  float min_value;
+  float max_value;
+  float delta;
   int i;
 
   bytes_in = PG_GETARG_BYTEA_P(0);
@@ -363,10 +367,10 @@ Datum pg_kll_float_sketch_get_histogram(PG_FUNCTION_ARGS) {
     elog(ERROR, "at least two bins expected");
   }
 
-  float* split_points = palloc(sizeof(float) * (num_bins - 1));
-  const float min_value = kll_float_sketch_get_quantile(sketchptr, 0);
-  const float max_value = kll_float_sketch_get_quantile(sketchptr, 1);
-  const float delta = (max_value - min_value) / num_bins;
+  split_points = palloc(sizeof(float) * (num_bins - 1));
+  min_value = kll_float_sketch_get_quantile(sketchptr, 0);
+  max_value = kll_float_sketch_get_quantile(sketchptr, 1);
+  delta = (max_value - min_value) / num_bins;
   for (i = 0; i < num_bins - 1; i++) {
     split_points[i] = min_value + delta * (i + 1);
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org