@@ -85,7 +85,6 @@ class hyperloglog_impl {
8585 precision_{cuda::std::countr_zero (
8686 sketch_bytes (cuco::sketch_size_kb (static_cast <double >(sketch_span.size () / 1024.0 ))) /
8787 sizeof (register_type))},
88- register_mask_{(1ull << this ->precision_ ) - 1 },
8988 sketch_{reinterpret_cast <register_type*>(sketch_span.data ()),
9089 this ->sketch_bytes () / sizeof (register_type)}
9190 {
@@ -98,6 +97,16 @@ class hyperloglog_impl {
9897#endif
9998 }
10099
100+ /* *
101+ * @brief Copy constructor for hyperloglog_impl.
102+ *
103+ * @param other The hyperloglog_impl object to copy from
104+ */
105+ __host__ __device__ constexpr hyperloglog_impl (hyperloglog_impl const & other)
106+ : hash_{other.hash_ }, precision_{other.precision_ }, sketch_{other.sketch_ }
107+ {
108+ }
109+
101110 /* *
102111 * @brief Resets the estimator, i.e., clears the current count estimate.
103112 *
@@ -150,8 +159,8 @@ class hyperloglog_impl {
150159 __device__ constexpr void add (T const & item) noexcept
151160 {
152161 auto const h = this ->hash_ (item);
153- auto const reg = h & this ->register_mask_ ;
154- auto const zeroes = cuda::std::countl_zero (h | this ->register_mask_ ) + 1 ; // __clz
162+ auto const reg = h & this ->register_mask () ;
163+ auto const zeroes = cuda::std::countl_zero (h | this ->register_mask () ) + 1 ; // __clz
155164
156165 // reversed order (same one as Spark uses)
157166 // auto const reg = h >> ((sizeof(hash_value_type) * 8) - this->precision_);
@@ -572,9 +581,18 @@ class hyperloglog_impl {
572581 }
573582 }
574583
584+ /* *
585+ * @brief Gets the register mask used to separate register index from count.
586+ *
587+ * @return The register mask
588+ */
589+ __host__ __device__ constexpr hash_value_type register_mask () const noexcept
590+ {
591+ return (1ull << this ->precision_ ) - 1 ;
592+ }
593+
575594 hasher hash_; // /< Hash function used to hash items
576595 int32_t precision_; // /< HLL precision parameter
577- hash_value_type register_mask_; // /< Mask used to separate register index from count
578596 cuda::std::span<register_type> sketch_; // /< HLL sketch storage
579597
580598 template <class T_ , cuda::thread_scope Scope_, class Hash_ >
0 commit comments