You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by jm...@apache.org on 2022/01/05 00:42:09 UTC

[datasketches-cpp] branch req_fix created (now 227528f)

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

jmalkin pushed a change to branch req_fix
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git.


      at 227528f  Addresses segfault described in issue #256

This branch includes the following new commits:

     new 227528f  Addresses segfault described in issue #256

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-cpp] 01/01: Addresses segfault described in issue #256

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

jmalkin pushed a commit to branch req_fix
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git

commit 227528fbf9377d67317c78d93b61b9ba5cf7e05c
Author: Jon Malkin <jm...@users.noreply.github.com>
AuthorDate: Tue Jan 4 16:41:31 2022 -0800

    Addresses segfault described in issue #256
---
 req/include/req_sketch_impl.hpp | 1 +
 req/test/req_sketch_test.cpp    | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/req/include/req_sketch_impl.hpp b/req/include/req_sketch_impl.hpp
index 7648546..91570e2 100755
--- a/req/include/req_sketch_impl.hpp
+++ b/req/include/req_sketch_impl.hpp
@@ -210,6 +210,7 @@ template<typename T, typename C, typename S, typename A>
 template<bool inclusive>
 auto req_sketch<T, C, S, A>::get_PMF(const T* split_points, uint32_t size) const -> vector_double {
   auto buckets = get_CDF<inclusive>(split_points, size);
+  if (is_empty()) return buckets;
   for (uint32_t i = size; i > 0; --i) {
     buckets[i] -= buckets[i - 1];
   }
diff --git a/req/test/req_sketch_test.cpp b/req/test/req_sketch_test.cpp
index a301a04..0d2da32 100755
--- a/req/test/req_sketch_test.cpp
+++ b/req/test/req_sketch_test.cpp
@@ -51,6 +51,10 @@ TEST_CASE("req sketch: empty", "[req_sketch]") {
   REQUIRE(std::isnan(sketch.get_quantile(1)));
   const double ranks[3] {0, 0.5, 1};
   REQUIRE(sketch.get_quantiles(ranks, 3).size() == 0);
+
+  const float split_points[1] {0};
+  REQUIRE(sketch.get_CDF(split_points, 1).empty());
+  REQUIRE(sketch.get_PMF(split_points, 1).empty());
 }
 
 TEST_CASE("req sketch: single value, lra", "[req_sketch]") {

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