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 2020/10/12 22:24:05 UTC

[incubator-datasketches-cpp] 01/01: use aod instead of std::vector, added test

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

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

commit 3a60331e65f1286ccfde1e87f1a3ec0a9f89e765
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Oct 12 15:23:50 2020 -0700

    use aod instead of std::vector, added test
---
 tuple/include/array_of_doubles_a_not_b.hpp  |  6 +++---
 tuple/test/array_of_doubles_sketch_test.cpp | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/tuple/include/array_of_doubles_a_not_b.hpp b/tuple/include/array_of_doubles_a_not_b.hpp
index c2bbc4e..67e14ca 100644
--- a/tuple/include/array_of_doubles_a_not_b.hpp
+++ b/tuple/include/array_of_doubles_a_not_b.hpp
@@ -29,10 +29,10 @@
 namespace datasketches {
 
 template<typename Allocator = std::allocator<double>>
-class array_of_doubles_a_not_b_alloc: tuple_a_not_b<std::vector<double, Allocator>, AllocVectorDouble<Allocator>> {
+class array_of_doubles_a_not_b_alloc: tuple_a_not_b<aod<Allocator>, AllocAOD<Allocator>> {
 public:
-  using Summary = std::vector<double, Allocator>;
-  using AllocSummary = AllocVectorDouble<Allocator>;
+  using Summary = aod<Allocator>;
+  using AllocSummary = AllocAOD<Allocator>;
   using Base = tuple_a_not_b<Summary, AllocSummary>;
   using CompactSketch = compact_array_of_doubles_sketch_alloc<Allocator>;
 
diff --git a/tuple/test/array_of_doubles_sketch_test.cpp b/tuple/test/array_of_doubles_sketch_test.cpp
index fa5fc92..7a5e359 100644
--- a/tuple/test/array_of_doubles_sketch_test.cpp
+++ b/tuple/test/array_of_doubles_sketch_test.cpp
@@ -26,6 +26,7 @@
 #include <array_of_doubles_sketch.hpp>
 #include <array_of_doubles_union.hpp>
 #include <array_of_doubles_intersection.hpp>
+#include <array_of_doubles_a_not_b.hpp>
 
 namespace datasketches {
 
@@ -280,4 +281,18 @@ TEST_CASE("aod intersection: half overlap", "[tuple_sketch]") {
   REQUIRE(result.get_estimate() == Approx(500).margin(0.01));
 }
 
+TEST_CASE("aod a-not-b: half overlap", "[tuple_sketch]") {
+  double a[1] = {1};
+
+  auto update_sketch1 = update_array_of_doubles_sketch::builder().build();
+  for (int i = 0; i < 1000; ++i) update_sketch1.update(i, a);
+
+  auto update_sketch2 = update_array_of_doubles_sketch::builder().build();
+  for (int i = 500; i < 1500; ++i) update_sketch2.update(i, a);
+
+  array_of_doubles_a_not_b a_not_b;
+  auto result = a_not_b.compute(update_sketch1, update_sketch2);
+  REQUIRE(result.get_estimate() == Approx(500).margin(0.01));
+}
+
 } /* namespace datasketches */


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