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/18 00:15:57 UTC

[datasketches-postgresql] branch core_4_0_0_compatibility created (now 1910837)

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

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


      at 1910837  compatibility with upcoming version 4.0.0

This branch includes the following new commits:

     new 1910837  compatibility with upcoming version 4.0.0

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: compatibility with upcoming version 4.0.0

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

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

commit 19108374e5563ca98c0651e25151be18e0bb7dce
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Thu Nov 17 16:15:27 2022 -0800

    compatibility with upcoming version 4.0.0
---
 src/frequent_strings_sketch_c_adapter.cpp |  8 ++++----
 src/kll_double_sketch_c_adapter.cpp       |  2 +-
 src/kll_float_sketch_c_adapter.cpp        |  2 +-
 src/req_float_sketch_c_adapter.cpp        | 28 ++++++----------------------
 4 files changed, 12 insertions(+), 28 deletions(-)

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 @@ struct serde_string {
   }
 };
 
-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 @@ ptr_with_size frequent_strings_sketch_serialize(const void* sketchptr, unsigned
   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 @@ ptr_with_size frequent_strings_sketch_serialize(const void* sketchptr, unsigned
 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 @@ void* frequent_strings_sketch_deserialize(const char* buffer, unsigned length) {
 
 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 @@ void req_float_sketch_merge(void* sketchptr1, void* sketchptr2) {
 
 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 @@ double req_float_sketch_get_rank(const void* sketchptr, float value, bool inclus
 
 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 @@ unsigned req_float_sketch_get_serialized_size_bytes(const void* sketchptr) {
 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_pmf_or_cdf(const void* sketchptr, const float* split
 
 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]);


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