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 2020/04/29 02:23:52 UTC

[incubator-datasketches-cpp] 01/07: remove hll union serialization, fix a few unused variable warnings

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

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

commit 92c3d309d78c91ae09b810c49bb2b6b05fa6d923
Author: Jon Malkin <jm...@users.noreply.github.com>
AuthorDate: Mon Apr 27 12:38:36 2020 -0700

    remove hll union serialization, fix a few unused variable warnings
---
 .../CompositeInterpolationXTable-internal.hpp      |  6 +-
 hll/include/CompositeInterpolationXTable.hpp       |  6 +-
 hll/include/HllUnion-internal.hpp                  | 20 ------
 hll/include/HllUtil.hpp                            |  2 +-
 hll/include/hll.hpp                                | 31 +---------
 hll/test/HllUnionTest.cpp                          | 72 ----------------------
 6 files changed, 8 insertions(+), 129 deletions(-)

diff --git a/hll/include/CompositeInterpolationXTable-internal.hpp b/hll/include/CompositeInterpolationXTable-internal.hpp
index a3d0302..10aa047 100644
--- a/hll/include/CompositeInterpolationXTable-internal.hpp
+++ b/hll/include/CompositeInterpolationXTable-internal.hpp
@@ -36,7 +36,7 @@ static const int yStrides[] =
   {1, 2, 3, 5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920};
 
 template<typename A>
-const int CompositeInterpolationXTable<A>::get_y_stride(const int logK) {
+int CompositeInterpolationXTable<A>::get_y_stride(const int logK) {
   if (logK < HllUtil<A>::MIN_LOG_K || logK > HllUtil<A>::MAX_LOG_K) {
     throw std::invalid_argument("logK must be in range [" + std::to_string(HllUtil<A>::MIN_LOG_K)
                                 + ", " + std::to_string(HllUtil<A>::MAX_LOG_K) + "]. Found: "
@@ -46,7 +46,7 @@ const int CompositeInterpolationXTable<A>::get_y_stride(const int logK) {
 }
 
 template<typename A>
-const int CompositeInterpolationXTable<A>::get_x_arr_length(const int logK) {
+int CompositeInterpolationXTable<A>::get_x_arr_length() {
   return numXArrValues;
 }
 
@@ -797,7 +797,7 @@ static const double xArr[18][numXArrValues] = {
 };
 
 template<typename A>
-const double* const CompositeInterpolationXTable<A>::get_x_arr(const int logK) {
+const double* CompositeInterpolationXTable<A>::get_x_arr(const int logK) {
   if (logK < HllUtil<A>::MIN_LOG_K || logK > HllUtil<A>::MAX_LOG_K) {
     throw std::invalid_argument("logK must be in range [" + std::to_string(HllUtil<A>::MIN_LOG_K)
                                 + ", " + std::to_string(HllUtil<A>::MAX_LOG_K) + "]. Found: "
diff --git a/hll/include/CompositeInterpolationXTable.hpp b/hll/include/CompositeInterpolationXTable.hpp
index 67563c5..8baecbe 100644
--- a/hll/include/CompositeInterpolationXTable.hpp
+++ b/hll/include/CompositeInterpolationXTable.hpp
@@ -27,10 +27,10 @@ namespace datasketches {
 template<typename A = std::allocator<char>>
 class CompositeInterpolationXTable {
   public:
-    static const int get_y_stride(int logK);
+    static int get_y_stride(int logK);
 
-    static const double* const get_x_arr(int logK);
-    static const int get_x_arr_length(int logK);
+    static const double* get_x_arr(int logK);
+    static int get_x_arr_length();
 };
 
 }
diff --git a/hll/include/HllUnion-internal.hpp b/hll/include/HllUnion-internal.hpp
index 0d039f2..a20efbc 100644
--- a/hll/include/HllUnion-internal.hpp
+++ b/hll/include/HllUnion-internal.hpp
@@ -163,26 +163,6 @@ void hll_union_alloc<A>::coupon_update(const int coupon) {
 }
 
 template<typename A>
-vector_u8<A> hll_union_alloc<A>::serialize_compact() const {
-  return gadget.serialize_compact();
-}
-
-template<typename A>
-vector_u8<A> hll_union_alloc<A>::serialize_updatable() const {
-  return gadget.serialize_updatable();
-}
-
-template<typename A>
-void hll_union_alloc<A>::serialize_compact(std::ostream& os) const {
-  return gadget.serialize_compact(os);
-}
-
-template<typename A>
-void hll_union_alloc<A>::serialize_updatable(std::ostream& os) const {
-  return gadget.serialize_updatable(os);
-}
-
-template<typename A>
 std::ostream& hll_union_alloc<A>::to_string(std::ostream& os, const bool summary,
                                   const bool detail, const bool aux_detail, const bool all) const {
   return gadget.to_string(os, summary, detail, aux_detail, all);
diff --git a/hll/include/HllUtil.hpp b/hll/include/HllUtil.hpp
index 8408d37..1bea84a 100644
--- a/hll/include/HllUtil.hpp
+++ b/hll/include/HllUtil.hpp
@@ -155,7 +155,7 @@ inline int HllUtil<A>::coupon(const HashState& hashState) {
 
 template<typename A>
 inline void HllUtil<A>::hash(const void* key, const int keyLen, const uint64_t seed, HashState& result) {
-  MurmurHash3_x64_128(key, keyLen, DEFAULT_SEED, result);
+  MurmurHash3_x64_128(key, keyLen, seed, result);
 }
 
 template<typename A>
diff --git a/hll/include/hll.hpp b/hll/include/hll.hpp
index 31db794..970bab8 100644
--- a/hll/include/hll.hpp
+++ b/hll/include/hll.hpp
@@ -547,39 +547,10 @@ class hll_union_alloc {
      */
     hll_sketch_alloc<A> get_result(target_hll_type tgt_type = HLL_4) const;
 
-    typedef vector_u8<A> vector_bytes; // alias for users
-
-    /**
-     * Serializes the sketch to a byte array, compacting data structures
-     * where feasible to eliminate unused storage in the serialized image.
-     * @param header_size_bytes Allows for PostgreSQL integration
-     */
-    vector_bytes serialize_compact() const;
-  
-    /**
-     * Serializes the sketch to a byte array, retaining all internal 
-     * data structures in their current form.
-     */
-    vector_bytes serialize_updatable() const;
-
-    /**
-     * Serializes the sketch to an ostream, compacting data structures
-     * where feasible to eliminate unused storage in the serialized image.
-     * @param os std::ostream to use for output.
-     */
-    void serialize_compact(std::ostream& os) const;
-
-    /**
-     * Serializes the sketch to an ostream, retaining all internal data
-     * structures in their current form.
-     * @param os std::ostream to use for output.
-     */
-    void serialize_updatable(std::ostream& os) const;
-
     /**
      * Human readable summary with optional detail
      * @param os std::ostram to which the summary is written
-     * @param summary if true, output the sketch summary
+     * @param summary if true, output the union summary
      * @param detail if true, output the internal data array
      * @param auxDetail if true, output the internal Aux array, if it exists.
      * @param all if true, outputs all entries including empty ones
diff --git a/hll/test/HllUnionTest.cpp b/hll/test/HllUnionTest.cpp
index 23bdd1c..3250901 100644
--- a/hll/test/HllUnionTest.cpp
+++ b/hll/test/HllUnionTest.cpp
@@ -24,8 +24,6 @@
 
 namespace datasketches {
 
-static const int nArr[] = {1, 3, 10, 30, 100, 300, 1000, 3000, 10000, 30000};
-
 static int min(int a, int b) {
   return (a < b) ? a : b;
 }
@@ -175,55 +173,6 @@ TEST_CASE("hll union: check unions", "[hll_union]") {
   }
 }
 
-static void checkUnionEquality(hll_union& u1, hll_union& u2) {
-  hll_sketch sk1 = u1.get_result();
-  hll_sketch sk2 = u2.get_result();
-
-  REQUIRE(sk2.get_lg_config_k() == sk1.get_lg_config_k());
-  REQUIRE(sk1.get_lower_bound(1) == sk2.get_lower_bound(1));
-  REQUIRE(sk1.get_estimate() == sk2.get_estimate());
-  REQUIRE(sk1.get_upper_bound(1) == sk2.get_upper_bound(1));
-  REQUIRE(sk2.get_target_type() == sk1.get_target_type());
-}
-
-static void toFrom(const int lgConfigK, const target_hll_type tgtHllType, const int n) {
-  hll_union srcU(lgConfigK);
-  hll_sketch srcSk(lgConfigK, tgtHllType);
-  for (int i = 0; i < n; ++i) {
-    srcSk.update(i);
-  }
-  srcU.update(srcSk);
-
-  std::stringstream ss(std::ios::in | std::ios::out | std::ios::binary);
-  srcU.serialize_compact(ss);
-  hll_union dstU = hll_union::deserialize(ss);
-  checkUnionEquality(srcU, dstU);
-
-  auto bytes1 = srcU.serialize_compact();
-  dstU = hll_union::deserialize(bytes1.data(), bytes1.size());
-  checkUnionEquality(srcU, dstU);
-
-  ss.clear();
-  srcU.serialize_updatable(ss);
-  dstU = hll_union::deserialize(ss);
-  checkUnionEquality(srcU, dstU);
-
-  auto bytes2 = srcU.serialize_updatable();
-  dstU = hll_union::deserialize(bytes2.data(), bytes2.size());
-  checkUnionEquality(srcU, dstU);
-} 
-
-TEST_CASE("hll union: check to from", "[hll_union]") {
-  for (int i = 0; i < 10; ++i) {
-    int n = nArr[i];
-    for (int lgK = 4; lgK <= 13; ++lgK) {
-      toFrom(lgK, HLL_4, n);
-      toFrom(lgK, HLL_6, n);
-      toFrom(lgK, HLL_8, n);
-    }
-  }
-}
-
 TEST_CASE("hll union: check composite estimate", "[hll_union]") {
   hll_union u(12);
   REQUIRE(u.is_empty());
@@ -296,27 +245,6 @@ TEST_CASE("hll union: check conversions", "[hll_union]") {
   REQUIRE(est1 == est3);
 }
 
-// moved from UnionCaseTest in java
-TEST_CASE("hll union: check misc", "[hll_union]") {
-  hll_union u(12);
-  int bytes = u.get_compact_serialization_bytes();
-  REQUIRE(bytes == 8);
-  bytes = hll_union::get_max_serialization_bytes(7);
-  REQUIRE(bytes == 40 + 128);
-  double v = u.get_estimate();
-  REQUIRE(0.0 == v);
-  v = u.get_lower_bound(1);
-  REQUIRE(0.0 == v);
-  v = u.get_upper_bound(1);
-  REQUIRE(0.0 == v);
-  REQUIRE(u.is_empty());
-  u.reset();
-  REQUIRE(u.is_empty());
-  std::ostringstream oss(std::ios::binary);
-  u.serialize_compact(oss);
-  REQUIRE(static_cast<int>(oss.tellp()) == 8);
-}
-
 TEST_CASE("hll union: check input types", "[hll_union]") {
   hll_union u(8);
 


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