This is an automated email from the ASF dual-hosted git repository. alsay pushed a commit to branch kll_minor_cleanup in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git
commit 5a7b1e499c7f605b644bf8c6488e0df7f0aed0e0 Author: AlexanderSaydakov <[email protected]> AuthorDate: Thu Dec 24 14:03:47 2020 -0800 minor cleanup --- kll/include/kll_quantile_calculator_impl.hpp | 2 +- kll/include/kll_sketch.hpp | 12 ++++++------ kll/include/kll_sketch_impl.hpp | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/kll/include/kll_quantile_calculator_impl.hpp b/kll/include/kll_quantile_calculator_impl.hpp index cb92674..f580819 100644 --- a/kll/include/kll_quantile_calculator_impl.hpp +++ b/kll/include/kll_quantile_calculator_impl.hpp @@ -81,7 +81,7 @@ template <typename T, typename C, typename A> void kll_quantile_calculator<T, C, A>::convert_to_preceding_cummulative() { uint64_t subtotal = 0; for (auto& entry: entries_) { - const uint32_t new_subtotal = subtotal + entry.second; + const uint64_t new_subtotal = subtotal + entry.second; entry.second = subtotal; subtotal = new_subtotal; } diff --git a/kll/include/kll_sketch.hpp b/kll/include/kll_sketch.hpp index 8b3409c..a4530c9 100644 --- a/kll/include/kll_sketch.hpp +++ b/kll/include/kll_sketch.hpp @@ -315,8 +315,8 @@ class kll_sketch { * * <p>If the sketch is empty this returns an empty vector. * - * @param split_points an array of <i>m</i> unique, monotonically increasing float values - * that divide the real number line into <i>m+1</i> consecutive disjoint intervals. + * @param split_points an array of <i>m</i> unique, monotonically increasing values + * that divide the input domain into <i>m+1</i> consecutive disjoint intervals. * The definition of an "interval" is inclusive of the left split point (or minimum value) and * exclusive of the right split point, with the exception that the last interval will include * the maximum value. @@ -338,8 +338,8 @@ class kll_sketch { * * <p>If the sketch is empty this returns an empty vector. * - * @param split_points an array of <i>m</i> unique, monotonically increasing float values - * that divide the real number line into <i>m+1</i> consecutive disjoint intervals. + * @param split_points an array of <i>m</i> unique, monotonically increasing values + * that divide the input domain into <i>m+1</i> consecutive disjoint intervals. * The definition of an "interval" is inclusive of the left split point (or minimum value) and * exclusive of the right split point, with the exception that the last interval will include * the maximum value. @@ -401,7 +401,7 @@ class kll_sketch { * @param is input stream * @return an instance of a sketch */ - static kll_sketch<T, C, S, A> deserialize(std::istream& is); + static kll_sketch deserialize(std::istream& is); /** * This method deserializes a sketch from a given array of bytes. @@ -409,7 +409,7 @@ class kll_sketch { * @param size the size of the array * @return an instance of a sketch */ - static kll_sketch<T, C, S, A> deserialize(const void* bytes, size_t size); + static kll_sketch deserialize(const void* bytes, size_t size); /* * Gets the normalized rank error given k and pmf. diff --git a/kll/include/kll_sketch_impl.hpp b/kll/include/kll_sketch_impl.hpp index d051135..f0c5ff3 100644 --- a/kll/include/kll_sketch_impl.hpp +++ b/kll/include/kll_sketch_impl.hpp @@ -91,7 +91,7 @@ is_level_zero_sorted_(other.is_level_zero_sorted_) template<typename T, typename C, typename S, typename A> kll_sketch<T, C, S, A>& kll_sketch<T, C, S, A>::operator=(const kll_sketch& other) { - kll_sketch<T, C, S, A> copy(other); + kll_sketch copy(other); std::swap(k_, copy.k_); std::swap(m_, copy.m_); std::swap(min_k_, copy.min_k_); @@ -271,6 +271,7 @@ T kll_sketch<T, C, S, A>::get_quantile(double fraction) const { template<typename T, typename C, typename S, typename A> std::vector<T, A> kll_sketch<T, C, S, A>::get_quantiles(const double* fractions, uint32_t size) const { std::vector<T, A> quantiles; + quantiles.reserve(size); if (is_empty()) return quantiles; std::unique_ptr<kll_quantile_calculator<T, C, A>, std::function<void(kll_quantile_calculator<T, C, A>*)>> quantile_calculator; quantiles.reserve(size); @@ -469,9 +470,9 @@ kll_sketch<T, C, S, A> kll_sketch<T, C, S, A>::deserialize(std::istream& is) { check_serial_version(serial_version); check_family_id(family_id); + if (!is.good()) throw std::runtime_error("error reading from std::istream"); const bool is_empty(flags_byte & (1 << flags::IS_EMPTY)); - if (!is.good()) throw std::runtime_error("error reading from std::istream"); - if (is_empty) return kll_sketch<T, C, S, A>(k); + if (is_empty) return kll_sketch(k); uint64_t n; uint16_t min_k; @@ -524,8 +525,7 @@ kll_sketch<T, C, S, A> kll_sketch<T, C, S, A>::deserialize(std::istream& is) { // copy did not throw, repackage with destrtuctor max_value = std::unique_ptr<T, item_deleter>(max_value_buffer.release(), item_deleter()); } - if (!is.good()) - throw std::runtime_error("error reading from std::istream"); + if (!is.good()) throw std::runtime_error("error reading from std::istream"); return kll_sketch(k, min_k, n, num_levels, std::move(levels), std::move(items), capacity, std::move(min_value), std::move(max_value), is_level_zero_sorted); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
