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
The following commit(s) were added to refs/heads/cleanup-before-5.0.0 by this
push:
new 7718f30 more cleanup
7718f30 is described below
commit 7718f301dbfbf609d324f0ad8f4b856d164fca5e
Author: AlexanderSaydakov <[email protected]>
AuthorDate: Tue Oct 31 12:14:53 2023 -0700
more cleanup
---
common/include/quantiles_sorted_view.hpp | 5 +++--
kll/include/kll_sketch.hpp | 9 +++++----
kll/include/kll_sketch_impl.hpp | 17 +++++++++--------
kll/test/kll_sketch_test.cpp | 6 +++---
theta/include/theta_a_not_b.hpp | 2 +-
theta/include/theta_intersection.hpp | 3 ++-
theta/include/theta_sketch.hpp | 3 +--
theta/include/theta_union.hpp | 13 ++++++-------
tuple/include/array_tuple_a_not_b.hpp | 2 +-
tuple/include/array_tuple_intersection.hpp | 2 +-
tuple/include/tuple_a_not_b.hpp | 2 +-
tuple/include/tuple_intersection.hpp | 4 ++--
tuple/include/tuple_sketch.hpp | 7 +++----
tuple/include/tuple_union.hpp | 12 ++++++------
14 files changed, 44 insertions(+), 43 deletions(-)
diff --git a/common/include/quantiles_sorted_view.hpp
b/common/include/quantiles_sorted_view.hpp
index e6dc887..c3ab6af 100755
--- a/common/include/quantiles_sorted_view.hpp
+++ b/common/include/quantiles_sorted_view.hpp
@@ -214,8 +214,6 @@ public:
using Base = typename quantiles_sorted_view<T, C,
A>::Container::const_iterator;
using value_type = typename std::conditional<std::is_arithmetic<T>::value,
typename Base::value_type, std::pair<const T&, const uint64_t>>::type;
- const_iterator(const Base& it, const Base& begin): Base(it), begin(begin) {}
-
template<typename TT = T, typename
std::enable_if<std::is_arithmetic<TT>::value, int>::type = 0>
const value_type operator*() const { return Base::operator*(); }
@@ -239,6 +237,9 @@ public:
private:
Base begin;
+
+ friend class quantiles_sorted_view<T, C, A>;
+ const_iterator(const Base& it, const Base& begin): Base(it), begin(begin) {}
};
} /* namespace datasketches */
diff --git a/kll/include/kll_sketch.hpp b/kll/include/kll_sketch.hpp
index b4bdfe0..3953d60 100644
--- a/kll/include/kll_sketch.hpp
+++ b/kll/include/kll_sketch.hpp
@@ -34,6 +34,11 @@ namespace datasketches {
namespace kll_constants {
/// default value of parameter K
const uint16_t DEFAULT_K = 200;
+ const uint8_t DEFAULT_M = 8;
+ /// min value of parameter K
+ const uint16_t MIN_K = DEFAULT_M;
+ /// max value of parameter K
+ const uint16_t MAX_K = (1 << 16) - 1;
}
/**
@@ -171,10 +176,6 @@ class kll_sketch {
*/
using quantile_return_type = typename quantiles_sorted_view<T, C,
A>::quantile_return_type;
- static const uint8_t DEFAULT_M = 8;
- static const uint16_t MIN_K = DEFAULT_M;
- static const uint16_t MAX_K = (1 << 16) - 1;
-
explicit kll_sketch(uint16_t k = kll_constants::DEFAULT_K, const C&
comparator = C(), const A& allocator = A());
kll_sketch(const kll_sketch& other);
kll_sketch(kll_sketch&& other) noexcept;
diff --git a/kll/include/kll_sketch_impl.hpp b/kll/include/kll_sketch_impl.hpp
index 373767c..8608c73 100644
--- a/kll/include/kll_sketch_impl.hpp
+++ b/kll/include/kll_sketch_impl.hpp
@@ -37,7 +37,7 @@ kll_sketch<T, C, A>::kll_sketch(uint16_t k, const C&
comparator, const A& alloca
comparator_(comparator),
allocator_(allocator),
k_(k),
-m_(DEFAULT_M),
+m_(kll_constants::DEFAULT_M),
min_k_(k),
num_levels_(1),
is_level_zero_sorted_(false),
@@ -49,8 +49,9 @@ min_item_(),
max_item_(),
sorted_view_(nullptr)
{
- if (k < MIN_K || k > MAX_K) {
- throw std::invalid_argument("K must be >= " + std::to_string(MIN_K) + "
and <= " + std::to_string(MAX_K) + ": " + std::to_string(k));
+ if (k < kll_constants::MIN_K || k > kll_constants::MAX_K) {
+ throw std::invalid_argument("K must be >= " +
std::to_string(kll_constants::MIN_K) + " and <= "
+ + std::to_string(kll_constants::MAX_K) + ": " + std::to_string(k));
}
levels_[0] = levels_[1] = k;
items_ = allocator_.allocate(items_size_);
@@ -382,7 +383,7 @@ template<typename T, typename C, typename A>
template<typename TT, typename std::enable_if<std::is_arithmetic<TT>::value,
int>::type>
size_t kll_sketch<T, C, A>::get_max_serialized_size_bytes(uint16_t k, uint64_t
n) {
const uint8_t num_levels = kll_helper::ub_on_num_levels(n);
- const uint32_t max_num_retained = kll_helper::compute_total_capacity(k,
DEFAULT_M, num_levels);
+ const uint32_t max_num_retained = kll_helper::compute_total_capacity(k,
kll_constants::DEFAULT_M, num_levels);
// the last integer in the levels_ array is not serialized because it can be
derived
return DATA_START + num_levels * sizeof(uint32_t) + (max_num_retained + 2) *
sizeof(TT);
}
@@ -392,7 +393,7 @@ template<typename T, typename C, typename A>
template<typename TT, typename std::enable_if<!std::is_arithmetic<TT>::value,
int>::type>
size_t kll_sketch<T, C, A>::get_max_serialized_size_bytes(uint16_t k, uint64_t
n, size_t max_item_size_bytes) {
const uint8_t num_levels = kll_helper::ub_on_num_levels(n);
- const uint32_t max_num_retained = kll_helper::compute_total_capacity(k,
DEFAULT_M, num_levels);
+ const uint32_t max_num_retained = kll_helper::compute_total_capacity(k,
kll_constants::DEFAULT_M, num_levels);
// the last integer in the levels_ array is not serialized because it can be
derived
return DATA_START + num_levels * sizeof(uint32_t) + (max_num_retained + 2) *
max_item_size_bytes;
}
@@ -653,7 +654,7 @@ kll_sketch<T, C, A>::kll_sketch(uint16_t k, uint16_t min_k,
uint64_t n, uint8_t
comparator_(comparator),
allocator_(levels.get_allocator()),
k_(k),
-m_(DEFAULT_M),
+m_(kll_constants::DEFAULT_M),
min_k_(min_k),
num_levels_(num_levels),
is_level_zero_sorted_(is_level_zero_sorted),
@@ -895,8 +896,8 @@ uint32_t kll_sketch<T, C,
A>::get_num_retained_above_level_zero() const {
template<typename T, typename C, typename A>
void kll_sketch<T, C, A>::check_m(uint8_t m) {
- if (m != DEFAULT_M) {
- throw std::invalid_argument("Possible corruption: M must be " +
std::to_string(DEFAULT_M)
+ if (m != kll_constants::DEFAULT_M) {
+ throw std::invalid_argument("Possible corruption: M must be " +
std::to_string(kll_constants::DEFAULT_M)
+ ": " + std::to_string(m));
}
}
diff --git a/kll/test/kll_sketch_test.cpp b/kll/test/kll_sketch_test.cpp
index 672d065..692d0a5 100644
--- a/kll/test/kll_sketch_test.cpp
+++ b/kll/test/kll_sketch_test.cpp
@@ -49,9 +49,9 @@ TEST_CASE("kll sketch", "[kll_sketch]") {
test_allocator_total_bytes = 0;
SECTION("k limits") {
- kll_float_sketch sketch1(kll_float_sketch::MIN_K, std::less<float>(), 0);
// this should work
- kll_float_sketch sketch2(kll_float_sketch::MAX_K, std::less<float>(), 0);
// this should work
- REQUIRE_THROWS_AS(new kll_float_sketch(kll_float_sketch::MIN_K - 1,
std::less<float>(), 0), std::invalid_argument);
+ kll_float_sketch sketch1(kll_constants::MIN_K, std::less<float>(), 0); //
this should work
+ kll_float_sketch sketch2(kll_constants::MAX_K, std::less<float>(), 0); //
this should work
+ REQUIRE_THROWS_AS(new kll_float_sketch(kll_constants::MIN_K - 1,
std::less<float>(), 0), std::invalid_argument);
// MAX_K + 1 makes no sense because k is uint16_t
//std::cout << "sizeof(kll_sketch<float>)=" << sizeof(kll_sketch<float>)
<< "\n";
//std::cout << "sizeof(kll_sketch<double>)=" << sizeof(kll_sketch<double>)
<< "\n";
diff --git a/theta/include/theta_a_not_b.hpp b/theta/include/theta_a_not_b.hpp
index 6efcc93..e705711 100644
--- a/theta/include/theta_a_not_b.hpp
+++ b/theta/include/theta_a_not_b.hpp
@@ -54,7 +54,7 @@ public:
* 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
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return the result of A-not-B as a compact sketch
*/
template<typename FwdSketch, typename Sketch>
diff --git a/theta/include/theta_intersection.hpp
b/theta/include/theta_intersection.hpp
index 68f3240..9b82d27 100644
--- a/theta/include/theta_intersection.hpp
+++ b/theta/include/theta_intersection.hpp
@@ -43,6 +43,7 @@ public:
using Sketch = theta_sketch_alloc<Allocator>;
using CompactSketch = compact_theta_sketch_alloc<Allocator>;
+ // there is no payload in Theta sketch entry
struct nop_policy {
void operator()(uint64_t internal_entry, uint64_t incoming_entry) const {
unused(incoming_entry);
@@ -71,7 +72,7 @@ public:
* Produces a copy of the current state of the intersection.
* If update() was not called, the state is the infinite "universe",
* which is considered an undefined state, and throws an exception.
- * @param ordered optional flag to specify if ordered sketch should be
produced
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return the result of the intersection
*/
CompactSketch get_result(bool ordered = true) const;
diff --git a/theta/include/theta_sketch.hpp b/theta/include/theta_sketch.hpp
index 696b9cc..5fc15f6 100644
--- a/theta/include/theta_sketch.hpp
+++ b/theta/include/theta_sketch.hpp
@@ -331,7 +331,7 @@ public:
/**
* Converts this sketch to a compact sketch (ordered or unordered).
- * @param ordered optional flag to specify if ordered sketch should be
produced
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return compact sketch
*/
compact_theta_sketch_alloc<Allocator> compact(bool ordered = true) const;
@@ -498,7 +498,6 @@ private:
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;
diff --git a/theta/include/theta_union.hpp b/theta/include/theta_union.hpp
index 1ddfd0b..4c62f4f 100644
--- a/theta/include/theta_union.hpp
+++ b/theta/include/theta_union.hpp
@@ -45,6 +45,7 @@ public:
using CompactSketch = compact_theta_sketch_alloc<Allocator>;
using resize_factor = theta_constants::resize_factor;
+ // there is no payload in Theta sketch entry
struct nop_policy {
void operator()(uint64_t internal_entry, uint64_t incoming_entry) const {
unused(internal_entry);
@@ -57,22 +58,20 @@ public:
class builder;
/**
- * This method is to update the union with a given sketch
+ * Update the union with a given sketch
* @param sketch to update the union with
*/
template<typename FwdSketch>
void update(FwdSketch&& sketch);
/**
- * This method produces a copy of the current state of the union as a
compact sketch.
- * @param ordered optional flag to specify if ordered sketch should be
produced
+ * Produces a copy of the current state of the union as a compact sketch.
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return the result of the union
*/
CompactSketch get_result(bool ordered = true) const;
- /**
- * Reset the union to the initial empty state
- */
+ /// Reset the union to the initial empty state
void reset();
private:
@@ -89,7 +88,7 @@ public:
builder(const A& allocator = A());
/**
- * This is to create an instance of the union with predefined parameters.
+ * Create an instance of the union with predefined parameters.
* @return an instance of the union
*/
theta_union_alloc<A> build() const;
diff --git a/tuple/include/array_tuple_a_not_b.hpp
b/tuple/include/array_tuple_a_not_b.hpp
index 85b88ad..5493c2d 100644
--- a/tuple/include/array_tuple_a_not_b.hpp
+++ b/tuple/include/array_tuple_a_not_b.hpp
@@ -46,7 +46,7 @@ public:
* 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
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return the result of A-not-B as a compact sketch
*/
template<typename FwdSketch, typename Sketch>
diff --git a/tuple/include/array_tuple_intersection.hpp
b/tuple/include/array_tuple_intersection.hpp
index e7e25dd..5f6ef26 100644
--- a/tuple/include/array_tuple_intersection.hpp
+++ b/tuple/include/array_tuple_intersection.hpp
@@ -52,7 +52,7 @@ public:
* Produces a copy of the current state of the intersection.
* If update() was not called, the state is the infinite "universe",
* which is considered an undefined state, and throws an exception.
- * @param ordered optional flag to specify if ordered sketch should be
produced
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return the result of the intersection as a compact sketch
*/
CompactSketch get_result(bool ordered = true) const;
diff --git a/tuple/include/tuple_a_not_b.hpp b/tuple/include/tuple_a_not_b.hpp
index 46b4236..b2f133f 100644
--- a/tuple/include/tuple_a_not_b.hpp
+++ b/tuple/include/tuple_a_not_b.hpp
@@ -49,7 +49,7 @@ public:
* 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
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return the result of A-not-B as a compact sketch
*/
template<typename FwdSketch, typename Sketch>
diff --git a/tuple/include/tuple_intersection.hpp
b/tuple/include/tuple_intersection.hpp
index 36d21d9..12de7b7 100644
--- a/tuple/include/tuple_intersection.hpp
+++ b/tuple/include/tuple_intersection.hpp
@@ -28,7 +28,7 @@ namespace datasketches {
/*
// for types with defined + operation
template<typename Summary>
-struct example_intersection_policy {
+struct example_tuple_intersection_policy {
void operator()(Summary& summary, const Summary& other) const {
summary += other;
}
@@ -89,7 +89,7 @@ public:
* Produces a copy of the current state of the intersection.
* If update() was not called, the state is the infinite "universe",
* which is considered an undefined state, and throws an exception.
- * @param ordered optional flag to specify if ordered sketch should be
produced
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return the result of the intersection
*/
CompactSketch get_result(bool ordered = true) const;
diff --git a/tuple/include/tuple_sketch.hpp b/tuple/include/tuple_sketch.hpp
index 5cad9a5..383e573 100644
--- a/tuple/include/tuple_sketch.hpp
+++ b/tuple/include/tuple_sketch.hpp
@@ -194,7 +194,7 @@ protected:
// for types with defined default constructor and + operation
template<typename Summary, typename Update>
-struct default_update_policy {
+struct default_tuple_update_policy {
Summary create() const {
return Summary();
}
@@ -211,7 +211,7 @@ struct default_update_policy {
template<
typename Summary,
typename Update = Summary,
- typename Policy = default_update_policy<Summary, Update>,
+ typename Policy = default_tuple_update_policy<Summary, Update>,
typename Allocator = std::allocator<Summary>
>
class update_tuple_sketch: public tuple_sketch<Summary, Allocator> {
@@ -376,7 +376,7 @@ public:
/**
* Converts this sketch to a compact sketch (ordered or unordered).
- * @param ordered optional flag to specify if ordered sketch should be
produced
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return compact sketch
*/
compact_tuple_sketch<Summary, Allocator> compact(bool ordered = true) const;
@@ -575,7 +575,6 @@ 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;
diff --git a/tuple/include/tuple_union.hpp b/tuple/include/tuple_union.hpp
index 4799545..71612b6 100644
--- a/tuple/include/tuple_union.hpp
+++ b/tuple/include/tuple_union.hpp
@@ -27,7 +27,7 @@ namespace datasketches {
// for types with defined + operation
template<typename Summary>
-struct default_union_policy {
+struct default_tuple_union_policy {
void operator()(Summary& summary, const Summary& other) const {
summary += other;
}
@@ -39,7 +39,7 @@ struct default_union_policy {
*/
template<
typename Summary,
- typename Policy = default_union_policy<Summary>,
+ typename Policy = default_tuple_union_policy<Summary>,
typename Allocator = std::allocator<Summary>
>
class tuple_union {
@@ -71,15 +71,15 @@ public:
class builder;
/**
- * This method is to update the union with a given sketch
+ * Update the union with a given sketch
* @param sketch to update the union with
*/
template<typename FwdSketch>
void update(FwdSketch&& sketch);
/**
- * This method produces a copy of the current state of the union as a
compact sketch.
- * @param ordered optional flag to specify if ordered sketch should be
produced
+ * Produces a copy of the current state of the union as a compact sketch.
+ * @param ordered optional flag to specify if an ordered sketch should be
produced
* @return the result of the union
*/
CompactSketch get_result(bool ordered = true) const;
@@ -109,7 +109,7 @@ public:
builder(const P& policy = P(), const A& allocator = A());
/**
- * This is to create an instance of the union with predefined parameters.
+ * Create an instance of the union with predefined parameters.
* @return an instance of the union
*/
tuple_union build() const;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]