compatibility with upcoming version 4.0.0
diff --git a/src/frequent_strings_sketch_c_adapter.cpp b/src/frequent_strings_sketch_c_adapter.cpp
index b2b5ead..05e2f50 100644
--- a/src/frequent_strings_sketch_c_adapter.cpp
+++ b/src/frequent_strings_sketch_c_adapter.cpp
@@ -77,7 +77,7 @@
}
};
-typedef datasketches::frequent_items_sketch<string, uint64_t, hash_string, std::equal_to<string>, serde_string, palloc_allocator<string>> frequent_strings_sketch;
+using frequent_strings_sketch = datasketches::frequent_items_sketch<string, uint64_t, hash_string, std::equal_to<string>, palloc_allocator<string>>;
void* frequent_strings_sketch_new(unsigned lg_k) {
try {
@@ -130,7 +130,7 @@
try {
ptr_with_size p;
auto bytes = new (palloc(sizeof(frequent_strings_sketch::vector_bytes))) frequent_strings_sketch::vector_bytes(
- static_cast<const frequent_strings_sketch*>(sketchptr)->serialize(header_size)
+ static_cast<const frequent_strings_sketch*>(sketchptr)->serialize(header_size, serde_string())
);
p.ptr = bytes->data();
p.size = bytes->size();
@@ -144,7 +144,7 @@
void* frequent_strings_sketch_deserialize(const char* buffer, unsigned length) {
try {
frequent_strings_sketch* sketchptr = new (palloc(sizeof(frequent_strings_sketch)))
- frequent_strings_sketch(frequent_strings_sketch::deserialize(buffer, length));
+ frequent_strings_sketch(frequent_strings_sketch::deserialize(buffer, length, serde_string()));
return sketchptr;
} catch (std::exception& e) {
pg_error(e.what());
@@ -154,7 +154,7 @@
unsigned frequent_strings_sketch_get_serialized_size_bytes(const void* sketchptr) {
try {
- return static_cast<const frequent_strings_sketch*>(sketchptr)->get_serialized_size_bytes();
+ return static_cast<const frequent_strings_sketch*>(sketchptr)->get_serialized_size_bytes(serde_string());
} catch (std::exception& e) {
pg_error(e.what());
}
diff --git a/src/kll_double_sketch_c_adapter.cpp b/src/kll_double_sketch_c_adapter.cpp
index e7f183f..db352bb 100644
--- a/src/kll_double_sketch_c_adapter.cpp
+++ b/src/kll_double_sketch_c_adapter.cpp
@@ -23,7 +23,7 @@
#include <kll_sketch.hpp>
-using kll_double_sketch = datasketches::kll_sketch<double, std::less<double>, datasketches::serde<double>, palloc_allocator<double>>;
+using kll_double_sketch = datasketches::kll_sketch<double, std::less<double>, palloc_allocator<double>>;
void* kll_double_sketch_new(unsigned k) {
try {
diff --git a/src/kll_float_sketch_c_adapter.cpp b/src/kll_float_sketch_c_adapter.cpp
index f9e7e2c..230348f 100644
--- a/src/kll_float_sketch_c_adapter.cpp
+++ b/src/kll_float_sketch_c_adapter.cpp
@@ -23,7 +23,7 @@
#include <kll_sketch.hpp>
-using kll_float_sketch = datasketches::kll_sketch<float, std::less<float>, datasketches::serde<float>, palloc_allocator<float>>;
+using kll_float_sketch = datasketches::kll_sketch<float, std::less<float>, palloc_allocator<float>>;
void* kll_float_sketch_new(unsigned k) {
try {
diff --git a/src/req_float_sketch_c_adapter.cpp b/src/req_float_sketch_c_adapter.cpp
index 0136a2f..d5b4319 100644
--- a/src/req_float_sketch_c_adapter.cpp
+++ b/src/req_float_sketch_c_adapter.cpp
@@ -23,7 +23,7 @@
#include <req_sketch.hpp>
-using req_float_sketch = datasketches::req_sketch<float, std::less<float>, datasketches::serde<float>, palloc_allocator<float>>;
+using req_float_sketch = datasketches::req_sketch<float, std::less<float>, palloc_allocator<float>>;
void* req_float_sketch_new(unsigned k, bool hra) {
try {
@@ -61,11 +61,7 @@
double req_float_sketch_get_rank(const void* sketchptr, float value, bool inclusive) {
try {
- if (inclusive) {
- return static_cast<const req_float_sketch*>(sketchptr)->get_rank<true>(value);
- } else {
- return static_cast<const req_float_sketch*>(sketchptr)->get_rank<false>(value);
- }
+ return static_cast<const req_float_sketch*>(sketchptr)->get_rank(value, inclusive);
} catch (std::exception& e) {
pg_error(e.what());
}
@@ -74,11 +70,7 @@
float req_float_sketch_get_quantile(const void* sketchptr, double rank, bool inclusive) {
try {
- if (inclusive) {
- return static_cast<const req_float_sketch*>(sketchptr)->get_quantile<true>(rank);
- } else {
- return static_cast<const req_float_sketch*>(sketchptr)->get_quantile<false>(rank);
- }
+ return static_cast<const req_float_sketch*>(sketchptr)->get_quantile(rank, inclusive);
} catch (std::exception& e) {
pg_error(e.what());
}
@@ -143,14 +135,8 @@
Datum* req_float_sketch_get_pmf_or_cdf(const void* sketchptr, const float* split_points, unsigned num_split_points, bool is_cdf, bool scale, bool inclusive) {
try {
auto array = is_cdf ?
- (inclusive ?
- static_cast<const req_float_sketch*>(sketchptr)->get_CDF<true>(split_points, num_split_points) :
- static_cast<const req_float_sketch*>(sketchptr)->get_CDF<false>(split_points, num_split_points)
- ) :
- (inclusive ?
- static_cast<const req_float_sketch*>(sketchptr)->get_PMF<true>(split_points, num_split_points) :
- static_cast<const req_float_sketch*>(sketchptr)->get_PMF<false>(split_points, num_split_points)
- );
+ static_cast<const req_float_sketch*>(sketchptr)->get_CDF(split_points, num_split_points, inclusive) :
+ static_cast<const req_float_sketch*>(sketchptr)->get_PMF(split_points, num_split_points, inclusive);
Datum* pmf = (Datum*) palloc(sizeof(Datum) * (num_split_points + 1));
const uint64_t n = static_cast<const req_float_sketch*>(sketchptr)->get_n();
for (unsigned i = 0; i < num_split_points + 1; i++) {
@@ -169,9 +155,7 @@
Datum* req_float_sketch_get_quantiles(const void* sketchptr, const double* fractions, unsigned num_fractions, bool inclusive) {
try {
- auto array = inclusive ?
- static_cast<const req_float_sketch*>(sketchptr)->get_quantiles<true>(fractions, num_fractions) :
- static_cast<const req_float_sketch*>(sketchptr)->get_quantiles<false>(fractions, num_fractions);
+ auto array = static_cast<const req_float_sketch*>(sketchptr)->get_quantiles(fractions, num_fractions, inclusive);
Datum* quantiles = (Datum*) palloc(sizeof(Datum) * num_fractions);
for (unsigned i = 0; i < num_fractions; i++) {
quantiles[i] = pg_float4_get_datum(array[i]);