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 2019/08/06 00:40:49 UTC

[incubator-datasketches-cpp] branch kll_test_allocator created (now dae0b6f)

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

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


      at dae0b6f  added test_allocator, renamed custom type A to test_type

This branch includes the following new commits:

     new dae0b6f  added test_allocator, renamed custom type A to test_type

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


[incubator-datasketches-cpp] 01/01: added test_allocator, renamed custom type A to test_type

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

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

commit dae0b6f9a9ee6013ea5f1ac2bc34fb7652d5fcec
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Aug 5 17:40:30 2019 -0700

    added test_allocator, renamed custom type A to test_type
---
 common/test/CMakeLists.txt                         |   4 +-
 common/test/test_allocator.cpp                     |  27 ++++++
 common/test/test_allocator.hpp                     | 105 +++++++++++++++++++++
 common/test/{A.hpp => test_type.hpp}               |  42 ++++-----
 fi/test/frequent_items_sketch_custom_type_test.cpp |  10 +-
 kll/test/kll_sketch_custom_type_test.cpp           |  26 +++--
 kll/test/kll_sketch_test.cpp                       |  89 ++++++++++-------
 7 files changed, 233 insertions(+), 70 deletions(-)

diff --git a/common/test/CMakeLists.txt b/common/test/CMakeLists.txt
index 908e57c..9af9e88 100644
--- a/common/test/CMakeLists.txt
+++ b/common/test/CMakeLists.txt
@@ -10,5 +10,7 @@ target_include_directories(common_test
 target_sources(common_test
   PRIVATE
     test_runner.cpp
-    A.hpp
+    test_type.hpp
+    test_allocator.hpp
+    test_allocator.cpp
 )
diff --git a/common/test/test_allocator.cpp b/common/test/test_allocator.cpp
new file mode 100644
index 0000000..02c5654
--- /dev/null
+++ b/common/test/test_allocator.cpp
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "test_allocator.hpp"
+
+namespace datasketches {
+
+// global variable to keep track of allocated size
+long long test_allocator_total_bytes = 0;
+
+} /* namespace datasketches */
diff --git a/common/test/test_allocator.hpp b/common/test/test_allocator.hpp
new file mode 100644
index 0000000..41dacfd
--- /dev/null
+++ b/common/test/test_allocator.hpp
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef TEST_ALLOCATOR_HPP
+#define TEST_ALLOCATOR_HPP
+
+#include <new>
+#include <utility>
+
+// this allocator keeps the total allocated size in a global variable for testing
+
+namespace datasketches {
+
+extern long long test_allocator_total_bytes;
+
+template <class T> class test_allocator {
+public:
+  typedef T                 value_type;
+  typedef value_type*       pointer;
+  typedef const value_type* const_pointer;
+  typedef value_type&       reference;
+  typedef const value_type& const_reference;
+  typedef std::size_t       size_type;
+  typedef std::ptrdiff_t    difference_type;
+
+  template <class U>
+  struct rebind { typedef test_allocator<U> other; };
+
+  test_allocator() {}
+  test_allocator(const test_allocator&) {}
+  template <class U>
+  test_allocator(const test_allocator<U>&) {}
+  ~test_allocator() {}
+
+  pointer address(reference x) const { return &x; }
+  const_pointer address(const_reference x) const {
+    return x;
+  }
+
+  pointer allocate(size_type n, const_pointer = 0) {
+    void* p = new char[n * sizeof(value_type)];
+    if (!p) throw std::bad_alloc();
+    test_allocator_total_bytes += n * sizeof(value_type);
+    return static_cast<pointer>(p);
+  }
+
+  void deallocate(pointer p, size_type n) {
+    if (p) delete[] (char*) p;
+    test_allocator_total_bytes -= n * sizeof(value_type);
+  }
+
+  size_type max_size() const {
+    return static_cast<size_type>(-1) / sizeof(value_type);
+  }
+
+  template<typename... Args>
+  void construct(pointer p, Args&&... args) {
+    new(p) value_type(std::forward<Args>(args)...);
+  }
+  void destroy(pointer p) { p->~value_type(); }
+
+private:
+  void operator=(const test_allocator&);
+};
+
+template<> class test_allocator<void> {
+public:
+  typedef void        value_type;
+  typedef void*       pointer;
+  typedef const void* const_pointer;
+
+  template <class U>
+  struct rebind { typedef test_allocator<U> other; };
+};
+
+
+template <class T>
+inline bool operator==(const test_allocator<T>&, const test_allocator<T>&) {
+  return true;
+}
+
+template <class T>
+inline bool operator!=(const test_allocator<T>&, const test_allocator<T>&) {
+  return false;
+}
+
+} /* namespace datasketches */
+
+#endif
diff --git a/common/test/A.hpp b/common/test/test_type.hpp
similarity index 69%
rename from common/test/A.hpp
rename to common/test/test_type.hpp
index 5c806c0..487da08 100644
--- a/common/test/A.hpp
+++ b/common/test/test_type.hpp
@@ -17,36 +17,36 @@
  * under the License.
  */
 
-#ifndef CLASS_A_HPP_
-#define CLASS_A_HPP_
+#ifndef CLASS_TEST_TYPE_HPP_
+#define CLASS_TEST_TYPE_HPP_
 
 #include <iostream>
 
 namespace datasketches {
 
-class A {
+class test_type {
   static const bool DEBUG = false;
 public:
   // no default constructor should be required
-  A(int value): value(value) {
+  test_type(int value): value(value) {
     if (DEBUG) std::cerr << "A constructor" << std::endl;
   }
-  ~A() {
+  ~test_type() {
     if (DEBUG) std::cerr << "A destructor" << std::endl;
   }
-  A(const A& other): value(other.value) {
+  test_type(const test_type& other): value(other.value) {
     if (DEBUG) std::cerr << "A copy constructor" << std::endl;
   }
   // noexcept is important here so that, for instance, std::vector could move this type
-  A(A&& other) noexcept : value(other.value) {
+  test_type(test_type&& other) noexcept : value(other.value) {
     if (DEBUG) std::cerr << "A move constructor" << std::endl;
   }
-  A& operator=(const A& other) {
+  test_type& operator=(const test_type& other) {
     if (DEBUG) std::cerr << "A copy assignment" << std::endl;
     value = other.value;
     return *this;
   }
-  A& operator=(A&& other) {
+  test_type& operator=(test_type&& other) {
     if (DEBUG) std::cerr << "A move assignment" << std::endl;
     value = other.value;
     return *this;
@@ -56,44 +56,44 @@ private:
   int value;
 };
 
-struct hashA {
-  std::size_t operator()(const A& a) const {
+struct test_type_hash {
+  std::size_t operator()(const test_type& a) const {
     return std::hash<int>()(a.get_value());
   }
 };
 
-struct equalA {
-  bool operator()(const A& a1, const A& a2) const {
+struct test_type_equal {
+  bool operator()(const test_type& a1, const test_type& a2) const {
     return a1.get_value() == a2.get_value();
   }
 };
 
-struct lessA {
-  bool operator()(const A& a1, const A& a2) const {
+struct test_type_less {
+  bool operator()(const test_type& a1, const test_type& a2) const {
     return a1.get_value() < a2.get_value();
   }
 };
 
-struct serdeA {
-  void serialize(std::ostream& os, const A* items, unsigned num) {
+struct test_type_serde {
+  void serialize(std::ostream& os, const test_type* items, unsigned num) {
     for (unsigned i = 0; i < num; i++) {
       const int value = items[i].get_value();
       os.write((char*)&value, sizeof(value));
     }
   }
-  void deserialize(std::istream& is, A* items, unsigned num) {
+  void deserialize(std::istream& is, test_type* items, unsigned num) {
     for (unsigned i = 0; i < num; i++) {
       int value;
       is.read((char*)&value, sizeof(value));
-      new (&items[i]) A(value);
+      new (&items[i]) test_type(value);
     }
   }
-  size_t size_of_item(const A& item) {
+  size_t size_of_item(const test_type& item) {
     return sizeof(int);
   }
 };
 
-std::ostream& operator<<(std::ostream& os, const A& a) {
+std::ostream& operator<<(std::ostream& os, const test_type& a) {
   os << a.get_value();
   return os;
 }
diff --git a/fi/test/frequent_items_sketch_custom_type_test.cpp b/fi/test/frequent_items_sketch_custom_type_test.cpp
index 4e7a794..3b938b8 100644
--- a/fi/test/frequent_items_sketch_custom_type_test.cpp
+++ b/fi/test/frequent_items_sketch_custom_type_test.cpp
@@ -21,11 +21,11 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include <frequent_items_sketch.hpp>
-#include <A.hpp>
+#include "../../common/test/test_type.hpp"
 
 namespace datasketches {
 
-typedef frequent_items_sketch<A, hashA, equalA, serdeA> frequent_A_sketch;
+typedef frequent_items_sketch<test_type, test_type_hash, test_type_equal, test_type_serde> frequent_test_type_sketch;
 
 class frequent_items_sketch_custom_type_test: public CppUnit::TestFixture {
 
@@ -35,7 +35,7 @@ class frequent_items_sketch_custom_type_test: public CppUnit::TestFixture {
 
   void custom_type() {
 
-    frequent_A_sketch sketch(3);
+    frequent_test_type_sketch sketch(3);
     sketch.update(1, 10); // should survive the purge
     sketch.update(2);
     sketch.update(3);
@@ -43,7 +43,7 @@ class frequent_items_sketch_custom_type_test: public CppUnit::TestFixture {
     sketch.update(5);
     sketch.update(6);
     sketch.update(7);
-    A a8(8);
+    test_type a8(8);
     sketch.update(a8);
     CPPUNIT_ASSERT(!sketch.is_empty());
     CPPUNIT_ASSERT_EQUAL(17, (int) sketch.get_total_weight());
@@ -60,7 +60,7 @@ class frequent_items_sketch_custom_type_test: public CppUnit::TestFixture {
     std::cerr << "serialize" << std::endl;
     sketch.serialize(s);
     std::cerr << "deserialize" << std::endl;
-    auto sketch2 = frequent_A_sketch::deserialize(s);
+    auto sketch2 = frequent_test_type_sketch::deserialize(s);
     CPPUNIT_ASSERT(!sketch2.is_empty());
     CPPUNIT_ASSERT_EQUAL(17, (int) sketch2.get_total_weight());
     CPPUNIT_ASSERT_EQUAL(10, (int) sketch2.get_estimate(1));
diff --git a/kll/test/kll_sketch_custom_type_test.cpp b/kll/test/kll_sketch_custom_type_test.cpp
index b781714..4e60024 100644
--- a/kll/test/kll_sketch_custom_type_test.cpp
+++ b/kll/test/kll_sketch_custom_type_test.cpp
@@ -21,11 +21,12 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include <kll_sketch.hpp>
-#include <A.hpp>
+#include <test_allocator.hpp>
+#include "../../common/test/test_type.hpp"
 
 namespace datasketches {
 
-typedef kll_sketch<A, lessA, serdeA> kll_sketch_a;
+typedef kll_sketch<test_type, test_type_less, test_type_serde, test_allocator<test_type>> kll_test_type_sketch;
 
 class kll_sketch_custom_type_test: public CppUnit::TestFixture {
 
@@ -35,8 +36,19 @@ class kll_sketch_custom_type_test: public CppUnit::TestFixture {
   CPPUNIT_TEST(merge_higher_levels);
   CPPUNIT_TEST_SUITE_END();
 
+public:
+  void setUp() {
+    test_allocator_total_bytes = 0;
+  }
+
+  void tearDown() {
+    if (test_allocator_total_bytes != 0) {
+      CPPUNIT_ASSERT_EQUAL((long long) 0, test_allocator_total_bytes);
+    }
+  }
+
   void compact_level_zero() {
-    kll_sketch_a sketch(8);
+    kll_test_type_sketch sketch(8);
     CPPUNIT_ASSERT_THROW(sketch.get_quantile(0), std::runtime_error);
     CPPUNIT_ASSERT_THROW(sketch.get_min_value(), std::runtime_error);
     CPPUNIT_ASSERT_THROW(sketch.get_max_value(), std::runtime_error);
@@ -61,10 +73,10 @@ class kll_sketch_custom_type_test: public CppUnit::TestFixture {
   }
 
   void merge_small() {
-    kll_sketch_a sketch1(8);
+    kll_test_type_sketch sketch1(8);
     sketch1.update(1);
 
-    kll_sketch_a sketch2(8);
+    kll_test_type_sketch sketch2(8);
     sketch2.update(2);
 
     sketch2.merge(sketch1);
@@ -78,7 +90,7 @@ class kll_sketch_custom_type_test: public CppUnit::TestFixture {
   }
 
   void merge_higher_levels() {
-    kll_sketch_a sketch1(8);
+    kll_test_type_sketch sketch1(8);
     sketch1.update(1);
     sketch1.update(2);
     sketch1.update(3);
@@ -89,7 +101,7 @@ class kll_sketch_custom_type_test: public CppUnit::TestFixture {
     sketch1.update(8);
     sketch1.update(9);
 
-    kll_sketch_a sketch2(8);
+    kll_test_type_sketch sketch2(8);
     sketch2.update(10);
     sketch2.update(11);
     sketch2.update(12);
diff --git a/kll/test/kll_sketch_test.cpp b/kll/test/kll_sketch_test.cpp
index 9c8c005..8e12791 100644
--- a/kll/test/kll_sketch_test.cpp
+++ b/kll/test/kll_sketch_test.cpp
@@ -17,14 +17,14 @@
  * under the License.
  */
 
-#include <kll_sketch.hpp>
-#include <kll_helper.hpp>
-
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 #include <cmath>
 #include <cstring>
 
+#include <kll_sketch.hpp>
+#include <test_allocator.hpp>
+
 namespace datasketches {
 
 static const double RANK_EPS_FOR_K_200 = 0.0133;
@@ -36,6 +36,11 @@ static std::string testBinaryInputPath = TEST_BINARY_INPUT_PATH;
 static std::string testBinaryInputPath = "test/";
 #endif
 
+// typical usage would be just kll_sketch<float> or kll_sketch<std::string>, but here we use test_allocator
+typedef kll_sketch<float, std::less<float>, serde<float>, test_allocator<float>> kll_float_sketch;
+// let std::string use the default allocator for simplicity, otherwise we need to define "less" and "serde"
+typedef kll_sketch<std::string, std::less<std::string>, serde<std::string>, test_allocator<std::string>> kll_string_sketch;
+
 class kll_sketch_test: public CppUnit::TestFixture {
 
   CPPUNIT_TEST_SUITE(kll_sketch_test);
@@ -66,15 +71,27 @@ class kll_sketch_test: public CppUnit::TestFixture {
   CPPUNIT_TEST(copy);
   CPPUNIT_TEST_SUITE_END();
 
+
+public:
+  void setUp() {
+    test_allocator_total_bytes = 0;
+  }
+
+  void tearDown() {
+    if (test_allocator_total_bytes != 0) {
+      CPPUNIT_ASSERT_EQUAL((long long) 0, test_allocator_total_bytes);
+    }
+  }
+
   void k_limits() {
-    kll_sketch<float> sketch1(kll_sketch<float>::MIN_K); // this should work
-    kll_sketch<float> sketch2(kll_sketch<float>::MAX_K); // this should work
-    CPPUNIT_ASSERT_THROW(new kll_sketch<float>(kll_sketch<float>::MIN_K - 1), std::invalid_argument);
+    kll_float_sketch sketch1(kll_float_sketch::MIN_K); // this should work
+    kll_float_sketch sketch2(kll_float_sketch::MAX_K); // this should work
+    CPPUNIT_ASSERT_THROW(new kll_float_sketch(kll_float_sketch::MIN_K - 1), std::invalid_argument);
     // MAX_K + 1 makes no sense because k is uint16_t
   }
 
   void empty() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     CPPUNIT_ASSERT(sketch.is_empty());
     CPPUNIT_ASSERT(!sketch.is_estimation_mode());
     CPPUNIT_ASSERT_EQUAL((uint64_t) 0, sketch.get_n());
@@ -98,13 +115,13 @@ class kll_sketch_test: public CppUnit::TestFixture {
 }
 
   void bad_get_quantile() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     sketch.update(0); // has to be non-empty to reach the check
     CPPUNIT_ASSERT_THROW(sketch.get_quantile(-1), std::invalid_argument);
   }
 
   void one_item() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     sketch.update(1);
     CPPUNIT_ASSERT(!sketch.is_empty());
     CPPUNIT_ASSERT(!sketch.is_estimation_mode());
@@ -131,7 +148,7 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void many_items_exact_mode() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     const uint32_t n(200);
     for (uint32_t i = 0; i < n; i++) {
       sketch.update(i);
@@ -159,7 +176,7 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void many_items_estimation_mode() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     const int n(1000000);
     for (int i = 0; i < n; i++) {
       sketch.update(i);
@@ -201,7 +218,7 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void consistency_between_get_rank_and_get_PMF_CDF() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     const int n = 1000;
     float values[n];
     for (int i = 0; i < n; i++) {
@@ -224,7 +241,7 @@ class kll_sketch_test: public CppUnit::TestFixture {
     std::ifstream is;
     is.exceptions(std::ios::failbit | std::ios::badbit);
     is.open(testBinaryInputPath + "kll_sketch_from_java.bin", std::ios::binary);
-    auto sketch = kll_sketch<float>::deserialize(is);
+    auto sketch = kll_float_sketch::deserialize(is);
     CPPUNIT_ASSERT(!sketch.is_empty());
     CPPUNIT_ASSERT(sketch.is_estimation_mode());
     CPPUNIT_ASSERT_EQUAL((uint64_t) 1000000, sketch.get_n());
@@ -234,11 +251,11 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void serialize_deserialize_empty() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
     sketch.serialize(s);
     CPPUNIT_ASSERT_EQUAL(sketch.get_serialized_size_bytes(), (uint32_t) s.tellp());
-    auto sketch2 = kll_sketch<float>::deserialize(s);
+    auto sketch2 = kll_float_sketch::deserialize(s);
     CPPUNIT_ASSERT_EQUAL(sketch2.get_serialized_size_bytes(), (uint32_t) s.tellg());
     CPPUNIT_ASSERT_EQUAL(sketch.is_empty(), sketch2.is_empty());
     CPPUNIT_ASSERT_EQUAL(sketch.is_estimation_mode(), sketch2.is_estimation_mode());
@@ -251,12 +268,12 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void serialize_deserialize_one_item() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     sketch.update(1);
     std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
     sketch.serialize(s);
     CPPUNIT_ASSERT_EQUAL(sketch.get_serialized_size_bytes(), (uint32_t) s.tellp());
-    auto sketch2 = kll_sketch<float>::deserialize(s);
+    auto sketch2 = kll_float_sketch::deserialize(s);
     CPPUNIT_ASSERT_EQUAL(sketch2.get_serialized_size_bytes(), (uint32_t) s.tellg());
     CPPUNIT_ASSERT_EQUAL(s.tellp(), s.tellg());
     CPPUNIT_ASSERT(!sketch2.is_empty());
@@ -274,7 +291,7 @@ class kll_sketch_test: public CppUnit::TestFixture {
     std::ifstream is;
     is.exceptions(std::ios::failbit | std::ios::badbit);
     is.open(testBinaryInputPath + "kll_sketch_float_one_item_v1.bin", std::ios::binary);
-    auto sketch = kll_sketch<float>::deserialize(is);
+    auto sketch = kll_float_sketch::deserialize(is);
     CPPUNIT_ASSERT(!sketch.is_empty());
     CPPUNIT_ASSERT(!sketch.is_estimation_mode());
     CPPUNIT_ASSERT_EQUAL((uint64_t) 1, sketch.get_n());
@@ -284,13 +301,13 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void serialize_deserialize_stream() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     const int n(1000);
     for (int i = 0; i < n; i++) sketch.update(i);
     std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
     sketch.serialize(s);
     CPPUNIT_ASSERT_EQUAL(sketch.get_serialized_size_bytes(), (uint32_t) s.tellp());
-    auto sketch2 = kll_sketch<float>::deserialize(s);
+    auto sketch2 = kll_float_sketch::deserialize(s);
     CPPUNIT_ASSERT_EQUAL(sketch2.get_serialized_size_bytes(), (uint32_t) s.tellg());
     CPPUNIT_ASSERT_EQUAL(s.tellp(), s.tellg());
     CPPUNIT_ASSERT_EQUAL(sketch.is_empty(), sketch2.is_empty());
@@ -307,12 +324,12 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void serialize_deserialize_bytes() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     const int n(1000);
     for (int i = 0; i < n; i++) sketch.update(i);
     auto data = sketch.serialize();
     CPPUNIT_ASSERT_EQUAL(sketch.get_serialized_size_bytes(), (uint32_t) data.second);
-    auto sketch2 = kll_sketch<float>::deserialize(data.first.get(), data.second);
+    auto sketch2 = kll_float_sketch::deserialize(data.first.get(), data.second);
     CPPUNIT_ASSERT_EQUAL(sketch2.get_serialized_size_bytes(), (uint32_t) data.second);
     CPPUNIT_ASSERT_EQUAL(sketch.is_empty(), sketch2.is_empty());
     CPPUNIT_ASSERT_EQUAL(sketch.is_estimation_mode(), sketch2.is_estimation_mode());
@@ -340,7 +357,7 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void out_of_order_split_points_float() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     sketch.update(0); // has too be non-empty to reach the check
     float split_points[2] = {1, 0};
     CPPUNIT_ASSERT_THROW(sketch.get_CDF(split_points, 2), std::invalid_argument);
@@ -354,15 +371,15 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void nan_split_point() {
-    kll_sketch<float> sketch;
+    kll_float_sketch sketch;
     sketch.update(0); // has too be non-empty to reach the check
     float split_points[1] = {std::numeric_limits<float>::quiet_NaN()};
     CPPUNIT_ASSERT_THROW(sketch.get_CDF(split_points, 1), std::invalid_argument);
   }
 
   void merge() {
-    kll_sketch<float> sketch1;
-    kll_sketch<float> sketch2;
+    kll_float_sketch sketch1;
+    kll_float_sketch sketch2;
     const int n = 10000;
     for (int i = 0; i < n; i++) {
       sketch1.update(i);
@@ -384,8 +401,8 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void merge_lower_k() {
-    kll_sketch<float> sketch1(256);
-    kll_sketch<float> sketch2(128);
+    kll_float_sketch sketch1(256);
+    kll_float_sketch sketch2(128);
     const int n = 10000;
     for (int i = 0; i < n; i++) {
       sketch1.update(i);
@@ -414,8 +431,8 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void merge_exact_mode_lower_k() {
-    kll_sketch<float> sketch1(256);
-    kll_sketch<float> sketch2(128);
+    kll_float_sketch sketch1(256);
+    kll_float_sketch sketch2(128);
     const int n = 10000;
     for (int i = 0; i < n; i++) {
       sketch1.update(i);
@@ -439,8 +456,8 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void merge_min_value_from_other() {
-    kll_sketch<float> sketch1;
-    kll_sketch<float> sketch2;
+    kll_float_sketch sketch1;
+    kll_float_sketch sketch2;
     sketch1.update(1);
     sketch2.update(2);
     sketch2.merge(sketch1);
@@ -449,9 +466,9 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void merge_min_and_max_from_other() {
-    kll_sketch<float> sketch1;
+    kll_float_sketch sketch1;
     for (int i = 0; i < 1000000; i++) sketch1.update(i);
-    kll_sketch<float> sketch2;
+    kll_float_sketch sketch2;
     sketch2.merge(sketch1);
     CPPUNIT_ASSERT_EQUAL(0.0f, sketch2.get_min_value());
     CPPUNIT_ASSERT_EQUAL(999999.0f, sketch2.get_max_value());
@@ -486,7 +503,7 @@ class kll_sketch_test: public CppUnit::TestFixture {
   }
 
   void sketch_of_strings() {
-    kll_sketch<std::string> sketch;
+    kll_string_sketch sketch;
     CPPUNIT_ASSERT_THROW(sketch.get_quantile(0), std::runtime_error);
     CPPUNIT_ASSERT_THROW(sketch.get_min_value(), std::runtime_error);
     CPPUNIT_ASSERT_THROW(sketch.get_max_value(), std::runtime_error);
@@ -501,7 +518,7 @@ class kll_sketch_test: public CppUnit::TestFixture {
     std::stringstream s(std::ios::in | std::ios::out | std::ios::binary);
     sketch.serialize(s);
     CPPUNIT_ASSERT_EQUAL(sketch.get_serialized_size_bytes(), (uint32_t) s.tellp());
-    auto sketch2 = kll_sketch<std::string>::deserialize(s);
+    auto sketch2 = kll_string_sketch::deserialize(s);
     CPPUNIT_ASSERT_EQUAL(sketch2.get_serialized_size_bytes(), (uint32_t) s.tellg());
     CPPUNIT_ASSERT_EQUAL(s.tellp(), s.tellg());
     CPPUNIT_ASSERT_EQUAL(sketch.is_empty(), sketch2.is_empty());


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