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

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

commit 1ef125f4f7d3fe09bc8c5269b302676ad64d753b
Author: AlexanderSaydakov <[email protected]>
AuthorDate: Fri Oct 27 20:56:47 2023 -0700

    cleanup
---
 cpc/include/cpc_sketch.hpp            |  2 +-
 hll/include/CouponList-internal.hpp   |  4 ++--
 hll/include/CouponList.hpp            |  4 +++-
 hll/include/HllArray-internal.hpp     |  6 +++---
 hll/include/HllArray.hpp              |  8 +++++---
 hll/include/HllSketch-internal.hpp    |  4 ++--
 hll/include/HllSketchImpl.hpp         |  4 +++-
 hll/include/hll.hpp                   | 35 ++++++++++++++++-------------------
 theta/include/theta_a_not_b.hpp       | 13 ++++++++-----
 theta/include/theta_intersection.hpp  |  9 ++++++---
 theta/include/theta_sketch.hpp        | 33 +++++++++++++++++++++------------
 theta/include/theta_union.hpp         |  9 ++++++---
 tuple/include/array_tuple_a_not_b.hpp |  4 ++--
 tuple/include/tuple_a_not_b.hpp       |  5 +++--
 tuple/include/tuple_intersection.hpp  |  3 ---
 tuple/include/tuple_sketch.hpp        | 11 +++++++----
 16 files changed, 88 insertions(+), 66 deletions(-)

diff --git a/cpc/include/cpc_sketch.hpp b/cpc/include/cpc_sketch.hpp
index 164c33a..77b2a35 100644
--- a/cpc/include/cpc_sketch.hpp
+++ b/cpc/include/cpc_sketch.hpp
@@ -33,7 +33,7 @@
 
 namespace datasketches {
 
-// forward-declarations
+// forward declarations
 template<typename A> class cpc_sketch_alloc;
 template<typename A> class cpc_union_alloc;
 
diff --git a/hll/include/CouponList-internal.hpp 
b/hll/include/CouponList-internal.hpp
index cd3d270..a240a00 100644
--- a/hll/include/CouponList-internal.hpp
+++ b/hll/include/CouponList-internal.hpp
@@ -169,9 +169,9 @@ CouponList<A>* CouponList<A>::newList(std::istream& is, 
const A& allocator) {
 }
 
 template<typename A>
-vector_u8<A> CouponList<A>::serialize(bool compact, unsigned 
header_size_bytes) const {
+auto CouponList<A>::serialize(bool compact, unsigned header_size_bytes) const 
-> vector_bytes {
   const size_t sketchSizeBytes = (compact ? getCompactSerializationBytes() : 
getUpdatableSerializationBytes()) + header_size_bytes;
-  vector_u8<A> byteArr(sketchSizeBytes, 0, getAllocator());
+  vector_bytes byteArr(sketchSizeBytes, 0, getAllocator());
   uint8_t* bytes = byteArr.data() + header_size_bytes;
 
   bytes[hll_constants::PREAMBLE_INTS_BYTE] = 
static_cast<uint8_t>(getPreInts());
diff --git a/hll/include/CouponList.hpp b/hll/include/CouponList.hpp
index cf0a662..f57b3a0 100644
--- a/hll/include/CouponList.hpp
+++ b/hll/include/CouponList.hpp
@@ -33,12 +33,14 @@ class HllSketchImplFactory;
 template<typename A>
 class CouponList : public HllSketchImpl<A> {
   public:
+    using vector_bytes = std::vector<uint8_t, typename 
std::allocator_traits<A>::template rebind_alloc<uint8_t>>;
+
     CouponList(uint8_t lgConfigK, target_hll_type tgtHllType, hll_mode mode, 
const A& allocator);
     CouponList(const CouponList& that, target_hll_type tgtHllType);
 
     static CouponList* newList(const void* bytes, size_t len, const A& 
allocator);
     static CouponList* newList(std::istream& is, const A& allocator);
-    virtual vector_u8<A> serialize(bool compact, unsigned header_size_bytes) 
const;
+    virtual vector_bytes serialize(bool compact, unsigned header_size_bytes) 
const;
     virtual void serialize(std::ostream& os, bool compact) const;
 
     virtual ~CouponList() = default;
diff --git a/hll/include/HllArray-internal.hpp 
b/hll/include/HllArray-internal.hpp
index 36d38b4..c3c6b3f 100644
--- a/hll/include/HllArray-internal.hpp
+++ b/hll/include/HllArray-internal.hpp
@@ -216,9 +216,9 @@ HllArray<A>* HllArray<A>::newHll(std::istream& is, const A& 
allocator) {
 }
 
 template<typename A>
-vector_u8<A> HllArray<A>::serialize(bool compact, unsigned header_size_bytes) 
const {
+auto HllArray<A>::serialize(bool compact, unsigned header_size_bytes) const -> 
vector_bytes {
   const size_t sketchSizeBytes = (compact ? getCompactSerializationBytes() : 
getUpdatableSerializationBytes()) + header_size_bytes;
-  vector_u8<A> byteArr(sketchSizeBytes, 0, getAllocator());
+  vector_bytes byteArr(sketchSizeBytes, 0, getAllocator());
   uint8_t* bytes = byteArr.data() + header_size_bytes;
   AuxHashMap<A>* auxHashMap = getAuxHashMap();
 
@@ -537,7 +537,7 @@ AuxHashMap<A>* HllArray<A>::getAuxHashMap() const {
 }
 
 template<typename A>
-const vector_u8<A>& HllArray<A>::getHllArray() const {
+auto HllArray<A>::getHllArray() const -> const vector_bytes& {
   return hllByteArr_;
 }
 
diff --git a/hll/include/HllArray.hpp b/hll/include/HllArray.hpp
index 589f0dd..471a140 100644
--- a/hll/include/HllArray.hpp
+++ b/hll/include/HllArray.hpp
@@ -31,13 +31,15 @@ class AuxHashMap;
 template<typename A>
 class HllArray : public HllSketchImpl<A> {
   public:
+    using vector_bytes = std::vector<uint8_t, typename 
std::allocator_traits<A>::template rebind_alloc<uint8_t>>;
+
     HllArray(uint8_t lgConfigK, target_hll_type tgtHllType, bool 
startFullSize, const A& allocator);
     explicit HllArray(const HllArray& other, target_hll_type tgtHllType);
 
     static HllArray* newHll(const void* bytes, size_t len, const A& allocator);
     static HllArray* newHll(std::istream& is, const A& allocator);
 
-    virtual vector_u8<A> serialize(bool compact, unsigned header_size_bytes) 
const;
+    virtual vector_bytes serialize(bool compact, unsigned header_size_bytes) 
const;
     virtual void serialize(std::ostream& os, bool compact) const;
 
     virtual ~HllArray() = default;
@@ -97,7 +99,7 @@ class HllArray : public HllSketchImpl<A> {
 
     virtual A getAllocator() const;
 
-    const vector_u8<A>& getHllArray() const;
+    const vector_bytes& getHllArray() const;
 
   protected:
     void hipAndKxQIncrementalUpdate(uint8_t oldValue, uint8_t newValue);
@@ -107,7 +109,7 @@ class HllArray : public HllSketchImpl<A> {
     double hipAccum_;
     double kxq0_;
     double kxq1_;
-    vector_u8<A> hllByteArr_; //init by sub-classes
+    vector_bytes hllByteArr_; //init by sub-classes
     uint8_t curMin_; //always zero for Hll6 and Hll8, only tracked by Hll4Array
     uint32_t numAtCurMin_; //interpreted as num zeros when curMin == 0
     bool oooFlag_; //Out-Of-Order Flag
diff --git a/hll/include/HllSketch-internal.hpp 
b/hll/include/HllSketch-internal.hpp
index dfd7e43..e60f08d 100644
--- a/hll/include/HllSketch-internal.hpp
+++ b/hll/include/HllSketch-internal.hpp
@@ -232,12 +232,12 @@ void 
hll_sketch_alloc<A>::serialize_updatable(std::ostream& os) const {
 }
 
 template<typename A>
-vector_u8<A> hll_sketch_alloc<A>::serialize_compact(unsigned 
header_size_bytes) const {
+auto hll_sketch_alloc<A>::serialize_compact(unsigned header_size_bytes) const 
-> vector_bytes {
   return sketch_impl->serialize(true, header_size_bytes);
 }
 
 template<typename A>
-vector_u8<A> hll_sketch_alloc<A>::serialize_updatable() const {
+auto hll_sketch_alloc<A>::serialize_updatable() const -> vector_bytes {
   return sketch_impl->serialize(false, 0);
 }
 
diff --git a/hll/include/HllSketchImpl.hpp b/hll/include/HllSketchImpl.hpp
index e437c21..8066719 100644
--- a/hll/include/HllSketchImpl.hpp
+++ b/hll/include/HllSketchImpl.hpp
@@ -30,11 +30,13 @@ namespace datasketches {
 template<typename A>
 class HllSketchImpl {
   public:
+    using vector_bytes = std::vector<uint8_t, typename 
std::allocator_traits<A>::template rebind_alloc<uint8_t>>;
+
     HllSketchImpl(uint8_t lgConfigK, target_hll_type tgtHllType, hll_mode 
mode, bool startFullSize);
     virtual ~HllSketchImpl();
 
     virtual void serialize(std::ostream& os, bool compact) const = 0;
-    virtual vector_u8<A> serialize(bool compact, unsigned header_size_bytes) 
const = 0;
+    virtual vector_bytes serialize(bool compact, unsigned header_size_bytes) 
const = 0;
 
     virtual HllSketchImpl* copy() const = 0;
     virtual HllSketchImpl* copyAs(target_hll_type tgtHllType) const = 0;
diff --git a/hll/include/hll.hpp b/hll/include/hll.hpp
index 1417c82..9d5f78f 100644
--- a/hll/include/hll.hpp
+++ b/hll/include/hll.hpp
@@ -29,7 +29,16 @@
 #include <vector>
 
 namespace datasketches {
-  
+
+// forward declarations
+template<typename A> class hll_sketch_alloc;
+template<typename A> class hll_union_alloc;
+
+/// HLL sketch alias with default allocator
+using hll_sketch = hll_sketch_alloc<std::allocator<uint8_t>>;
+/// HLL union alias with default allocator
+using hll_union = hll_union_alloc<std::allocator<uint8_t>>;
+
 /**
  * Specifies the target type of HLL sketch to be created. It is a target in 
that the actual
  * allocation of the HLL array is deferred until sufficient number of items 
have been received by
@@ -66,15 +75,6 @@ enum target_hll_type {
     HLL_8  ///< 8 bits per entry (fastest, fixed size)
 };
 
-template<typename A>
-class HllSketchImpl;
-
-template<typename A>
-class hll_union_alloc;
-
-template<typename A> using AllocU8 = typename 
std::allocator_traits<A>::template rebind_alloc<uint8_t>;
-template<typename A> using vector_u8 = std::vector<uint8_t, AllocU8<A>>;
-
 /**
  * This is a high performance implementation of Phillipe Flajolet's HLL sketch 
but with
  * significantly improved error behavior.  If the ONLY use case for sketching 
is counting
@@ -108,6 +108,9 @@ template<typename A> using vector_u8 = std::vector<uint8_t, 
AllocU8<A>>;
  * author Kevin Lang
  */
 
+// forward declaration
+template<typename A> class HllSketchImpl;
+
 template<typename A = std::allocator<uint8_t> >
 class hll_sketch_alloc final {
   public:
@@ -179,7 +182,9 @@ class hll_sketch_alloc final {
      */
     void reset();
 
-    using vector_bytes = vector_u8<A>; // alias for users
+    // This is a convenience alias for users
+    // The type returned by the following serialize method
+    using vector_bytes = std::vector<uint8_t, typename 
std::allocator_traits<A>::template rebind_alloc<uint8_t>>;
 
     /**
      * Serializes the sketch to a byte array, compacting data structures
@@ -408,8 +413,6 @@ class hll_sketch_alloc final {
     bool is_out_of_order_flag() const;
     bool is_estimation_mode() const;
 
-    typedef typename std::allocator_traits<A>::template 
rebind_alloc<hll_sketch_alloc> AllocHllSketch;
-
     HllSketchImpl<A>* sketch_impl;
     friend hll_union_alloc<A>;
 };
@@ -645,12 +648,6 @@ class hll_union_alloc {
     hll_sketch_alloc<A> gadget_;
 };
 
-/// HLL sketch alias with default allocator
-using hll_sketch = hll_sketch_alloc<std::allocator<uint8_t>>;
-
-/// HLL union alias with default allocator
-using hll_union = hll_union_alloc<std::allocator<uint8_t>>;
-
 } // namespace datasketches
 
 #include "hll.private.hpp"
diff --git a/theta/include/theta_a_not_b.hpp b/theta/include/theta_a_not_b.hpp
index f017994..6efcc93 100644
--- a/theta/include/theta_a_not_b.hpp
+++ b/theta/include/theta_a_not_b.hpp
@@ -25,6 +25,12 @@
 
 namespace datasketches {
 
+// forward declaration
+template<typename A> class theta_a_not_b_alloc;
+
+// alias with default allocator for convenience
+using theta_a_not_b = theta_a_not_b_alloc<std::allocator<uint64_t>>;
+
 /**
  * Theta A-not-B (set difference).
  * Computes set difference of Theta sketches.
@@ -45,11 +51,11 @@ public:
   explicit theta_a_not_b_alloc(uint64_t seed = DEFAULT_SEED, const Allocator& 
allocator = Allocator());
 
   /**
-   * Computes the a-not-b set operation given two sketches.
+   * Computes the A-not-B set operation given two sketches.
    * @param a sketch A
    * @param b sketch B
    * @param ordered optional flag to specify if ordered sketch should be 
produced
-   * @return the result of a-not-b as a compact sketch
+   * @return the result of A-not-B as a compact sketch
    */
   template<typename FwdSketch, typename Sketch>
   CompactSketch compute(FwdSketch&& a, const Sketch& b, bool ordered = true) 
const;
@@ -58,9 +64,6 @@ private:
   State state_;
 };
 
-// alias with default allocator for convenience
-using theta_a_not_b = theta_a_not_b_alloc<std::allocator<uint64_t>>;
-
 } /* namespace datasketches */
 
 #include "theta_a_not_b_impl.hpp"
diff --git a/theta/include/theta_intersection.hpp 
b/theta/include/theta_intersection.hpp
index 93a4a7c..68f3240 100644
--- a/theta/include/theta_intersection.hpp
+++ b/theta/include/theta_intersection.hpp
@@ -25,6 +25,12 @@
 
 namespace datasketches {
 
+// forward declaration
+template<typename A> class theta_intersection_alloc;
+
+// alias with default allocator for convenience
+using theta_intersection = theta_intersection_alloc<std::allocator<uint64_t>>;
+
 /**
  * Theta intersection.
  * Computes intersection of Theta sketches.
@@ -80,9 +86,6 @@ private:
   State state_;
 };
 
-// alias with default allocator for convenience
-using theta_intersection = theta_intersection_alloc<std::allocator<uint64_t>>;
-
 } /* namespace datasketches */
 
 #include "theta_intersection_impl.hpp"
diff --git a/theta/include/theta_sketch.hpp b/theta/include/theta_sketch.hpp
index a2d0776..696b9cc 100644
--- a/theta/include/theta_sketch.hpp
+++ b/theta/include/theta_sketch.hpp
@@ -25,6 +25,21 @@
 
 namespace datasketches {
 
+// forward declarations
+template<typename A> class theta_sketch_alloc;
+template<typename A> class update_theta_sketch_alloc;
+template<typename A> class compact_theta_sketch_alloc;
+template<typename A> class wrapped_compact_theta_sketch_alloc;
+
+/// Theta sketch alias with default allocator
+using theta_sketch = theta_sketch_alloc<std::allocator<uint64_t>>;
+/// Update Theta sketch alias with default allocator
+using update_theta_sketch = 
update_theta_sketch_alloc<std::allocator<uint64_t>>;
+/// Compact Theta sketch alias with default allocator
+using compact_theta_sketch = 
compact_theta_sketch_alloc<std::allocator<uint64_t>>;
+/// Wrapped Compact Theta sketch alias with default allocator
+using wrapped_compact_theta_sketch = 
wrapped_compact_theta_sketch_alloc<std::allocator<uint64_t>>;
+
 /// Abstract base class for Theta sketch
 template<typename Allocator = std::allocator<uint64_t>>
 class base_theta_sketch_alloc {
@@ -462,9 +477,6 @@ public:
   static compact_theta_sketch_alloc deserialize(const void* bytes, size_t size,
       uint64_t seed = DEFAULT_SEED, const Allocator& allocator = Allocator());
 
-  /// @private constructor for internal use
-  compact_theta_sketch_alloc(bool is_empty, bool is_ordered, uint16_t 
seed_hash, uint64_t theta, std::vector<uint64_t, Allocator>&& entries);
-
 private:
   enum flags { IS_BIG_ENDIAN, IS_READ_ONLY, IS_EMPTY, IS_COMPACT, IS_ORDERED };
 
@@ -485,6 +497,12 @@ private:
   static compact_theta_sketch_alloc deserialize_v4(uint8_t preamble_longs, 
std::istream& is, uint64_t seed, const Allocator& allocator);
 
   virtual void print_specifics(std::ostringstream& os) const;
+
+  // constructor for internal use
+  template<typename E, typename EK, typename P, typename S, typename CS, 
typename A> friend class theta_union_base;
+  template<typename E, typename EK, typename P, typename S, typename CS, 
typename A> friend class theta_intersection_base;
+  template<typename E, typename EK, typename CS, typename A> friend class 
theta_set_difference_base;
+  compact_theta_sketch_alloc(bool is_empty, bool is_ordered, uint16_t 
seed_hash, uint64_t theta, std::vector<uint64_t, Allocator>&& entries);
 };
 
 /// Update Theta sketch builder
@@ -580,15 +598,6 @@ private:
   uint64_t buffer_[8];
 };
 
-/// Theta sketch alias with default allocator
-using theta_sketch = theta_sketch_alloc<std::allocator<uint64_t>>;
-/// Update Theta sketch alias with default allocator
-using update_theta_sketch = 
update_theta_sketch_alloc<std::allocator<uint64_t>>;
-/// Compact Theta sketch alias with default allocator
-using compact_theta_sketch = 
compact_theta_sketch_alloc<std::allocator<uint64_t>>;
-/// Wrapped Compact Theta sketch alias with default allocator
-using wrapped_compact_theta_sketch = 
wrapped_compact_theta_sketch_alloc<std::allocator<uint64_t>>;
-
 } /* namespace datasketches */
 
 #include "theta_sketch_impl.hpp"
diff --git a/theta/include/theta_union.hpp b/theta/include/theta_union.hpp
index ca59629..1ddfd0b 100644
--- a/theta/include/theta_union.hpp
+++ b/theta/include/theta_union.hpp
@@ -26,6 +26,12 @@
 
 namespace datasketches {
 
+// forward declaration
+template<typename A> class theta_union_alloc;
+
+// alias with default allocator for convenience
+using theta_union = theta_union_alloc<std::allocator<uint64_t>>;
+
 /**
  * Theta Union.
  * Computes union of Theta sketches. There is no constructor. Use builder 
instead.
@@ -89,9 +95,6 @@ public:
   theta_union_alloc<A> build() const;
 };
 
-// alias with default allocator for convenience
-using theta_union = theta_union_alloc<std::allocator<uint64_t>>;
-
 } /* namespace datasketches */
 
 #include "theta_union_impl.hpp"
diff --git a/tuple/include/array_tuple_a_not_b.hpp 
b/tuple/include/array_tuple_a_not_b.hpp
index 6007cca..85b88ad 100644
--- a/tuple/include/array_tuple_a_not_b.hpp
+++ b/tuple/include/array_tuple_a_not_b.hpp
@@ -43,11 +43,11 @@ public:
   explicit array_tuple_a_not_b(uint64_t seed = DEFAULT_SEED, const Allocator& 
allocator = Allocator());
 
   /**
-   * Computes the a-not-b set operation given two sketches.
+   * Computes the A-not-B set operation given two sketches.
    * @param a sketch A
    * @param b sketch B
    * @param ordered optional flag to specify if ordered sketch should be 
produced
-   * @return the result of a-not-b as a compact sketch
+   * @return the result of A-not-B as a compact sketch
    */
   template<typename FwdSketch, typename Sketch>
   CompactSketch compute(FwdSketch&& a, const Sketch& b, bool ordered = true) 
const;
diff --git a/tuple/include/tuple_a_not_b.hpp b/tuple/include/tuple_a_not_b.hpp
index edcf812..46b4236 100644
--- a/tuple/include/tuple_a_not_b.hpp
+++ b/tuple/include/tuple_a_not_b.hpp
@@ -25,6 +25,7 @@
 
 namespace datasketches {
 
+/// tuple A-not-B
 template<
   typename Summary,
   typename Allocator = std::allocator<Summary>
@@ -45,11 +46,11 @@ public:
   explicit tuple_a_not_b(uint64_t seed = DEFAULT_SEED, const Allocator& 
allocator = Allocator());
 
   /**
-   * Computes the a-not-b set operation given two sketches.
+   * Computes the A-not-B set operation given two sketches.
    * @param a sketch A
    * @param b sketch B
    * @param ordered optional flag to specify if ordered sketch should be 
produced
-   * @return the result of a-not-b as a compact sketch
+   * @return the result of A-not-B as a compact sketch
    */
   template<typename FwdSketch, typename Sketch>
   CompactSketch compute(FwdSketch&& a, const Sketch& b, bool ordered = true) 
const;
diff --git a/tuple/include/tuple_intersection.hpp 
b/tuple/include/tuple_intersection.hpp
index f8445cb..36d21d9 100644
--- a/tuple/include/tuple_intersection.hpp
+++ b/tuple/include/tuple_intersection.hpp
@@ -32,9 +32,6 @@ struct example_intersection_policy {
   void operator()(Summary& summary, const Summary& other) const {
     summary += other;
   }
-  void operator()(Summary& summary, Summary&& other) const {
-    summary += other;
-  }
 };
 */
 
diff --git a/tuple/include/tuple_sketch.hpp b/tuple/include/tuple_sketch.hpp
index 7e07e71..5cad9a5 100644
--- a/tuple/include/tuple_sketch.hpp
+++ b/tuple/include/tuple_sketch.hpp
@@ -27,7 +27,7 @@
 
 namespace datasketches {
 
-// forward-declarations
+// forward declarations
 template<typename S, typename A> class tuple_sketch;
 template<typename S, typename U, typename P, typename A> class 
update_tuple_sketch;
 template<typename S, typename A> class compact_tuple_sketch;
@@ -530,9 +530,6 @@ public:
   static compact_tuple_sketch deserialize(const void* bytes, size_t size, 
uint64_t seed = DEFAULT_SEED,
       const SerDe& sd = SerDe(), const Allocator& allocator = Allocator());
 
-  // for internal use
-  compact_tuple_sketch(bool is_empty, bool is_ordered, uint16_t seed_hash, 
uint64_t theta, std::vector<Entry, AllocEntry>&& entries);
-
 protected:
   bool is_empty_;
   bool is_ordered_;
@@ -578,6 +575,12 @@ protected:
 
   virtual void print_specifics(std::ostringstream& os) const;
 
+  // for internal use
+  template<typename E, typename EK, typename P, typename S, typename CS, 
typename A> friend class theta_union_base;
+  template<typename E, typename EK, typename P, typename S, typename CS, 
typename A> friend class theta_intersection_base;
+  template<typename E, typename EK, typename CS, typename A> friend class 
theta_set_difference_base;
+  compact_tuple_sketch(bool is_empty, bool is_ordered, uint16_t seed_hash, 
uint64_t theta, std::vector<Entry, AllocEntry>&& entries);
+
 };
 
 /// Tuple base builder


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to