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/11/07 20:31:00 UTC

[datasketches-postgresql] branch standard_c created (now 62d457b)

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

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


      at 62d457b  use standard C

This branch includes the following new commits:

     new 62d457b  use standard C

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[datasketches-postgresql] 01/01: use standard C

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 62d457b672c34879f4682ffa7f7d3e38d2ef6275
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Nov 7 12:30:39 2022 -0800

    use standard C
---
 src/quantiles_double_sketch_pg_functions.c | 13 +++++++++----
 src/req_float_sketch_pg_functions.c        | 13 +++++++++----
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/quantiles_double_sketch_pg_functions.c b/src/quantiles_double_sketch_pg_functions.c
index dbc2b79..713e54e 100644
--- a/src/quantiles_double_sketch_pg_functions.c
+++ b/src/quantiles_double_sketch_pg_functions.c
@@ -345,6 +345,11 @@ Datum pg_quantiles_double_sketch_get_histogram(PG_FUNCTION_ARGS) {
   void* sketchptr;
   int num_bins;
 
+  double* split_points;
+  double min_value;
+  double max_value;
+  double delta;
+
   // output array of bins
   Datum* result;
   ArrayType* arr_out;
@@ -363,10 +368,10 @@ Datum pg_quantiles_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 = quantiles_double_sketch_get_quantile(sketchptr, 0);
-  const double max_value = quantiles_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 = quantiles_double_sketch_get_quantile(sketchptr, 0);
+  max_value = quantiles_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/req_float_sketch_pg_functions.c b/src/req_float_sketch_pg_functions.c
index a42de15..f2696bc 100644
--- a/src/req_float_sketch_pg_functions.c
+++ b/src/req_float_sketch_pg_functions.c
@@ -366,6 +366,11 @@ Datum pg_req_float_sketch_get_histogram(PG_FUNCTION_ARGS) {
   int num_bins;
   bool inclusive;
 
+  float* split_points;
+  float min_value;
+  float max_value;
+  float delta;
+
   // output array of bins
   Datum* result;
   ArrayType* arr_out;
@@ -386,10 +391,10 @@ Datum pg_req_float_sketch_get_histogram(PG_FUNCTION_ARGS) {
 
   inclusive = PG_NARGS() > 2 ? PG_GETARG_BOOL(2) : false;
 
-  float* split_points = palloc(sizeof(float) * (num_bins - 1));
-  const float min_value = req_float_sketch_get_quantile(sketchptr, 0, inclusive);
-  const float max_value = req_float_sketch_get_quantile(sketchptr, 1, inclusive);
-  const float delta = (max_value - min_value) / num_bins;
+  split_points = palloc(sizeof(float) * (num_bins - 1));
+  min_value = req_float_sketch_get_quantile(sketchptr, 0, inclusive);
+  max_value = req_float_sketch_get_quantile(sketchptr, 1, inclusive);
+  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