Merge pull request #51 from apache/kll_double
comply with standard C
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 @@
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 @@
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 @@
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 @@
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);
}