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 2022/01/14 10:29:49 UTC
[datasketches-cpp] branch quantiles updated: use the same random_bit implementation across all quantiles sketches, in common_defs.hpp
This is an automated email from the ASF dual-hosted git repository.
jmalkin pushed a commit to branch quantiles
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git
The following commit(s) were added to refs/heads/quantiles by this push:
new 6eccbc9 use the same random_bit implementation across all quantiles sketches, in common_defs.hpp
6eccbc9 is described below
commit 6eccbc9e8cc515e24319f61a3a34da0a5e276f04
Author: Jon Malkin <jm...@users.noreply.github.com>
AuthorDate: Fri Jan 14 02:29:35 2022 -0800
use the same random_bit implementation across all quantiles sketches, in common_defs.hpp
---
kll/include/kll_helper.hpp | 3 ---
kll/include/kll_helper_impl.hpp | 2 ++
req/include/req_common.hpp | 4 ----
req/include/req_compactor_impl.hpp | 5 +++--
4 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/kll/include/kll_helper.hpp b/kll/include/kll_helper.hpp
index c026538..e3789c2 100644
--- a/kll/include/kll_helper.hpp
+++ b/kll/include/kll_helper.hpp
@@ -26,9 +26,6 @@
namespace datasketches {
-static std::independent_bits_engine<std::mt19937, 1, uint32_t>
- random_bit(static_cast<uint32_t>(std::chrono::system_clock::now().time_since_epoch().count()));
-
#ifdef KLL_VALIDATION
extern uint32_t kll_next_offset;
#endif
diff --git a/kll/include/kll_helper_impl.hpp b/kll/include/kll_helper_impl.hpp
index caa611b..3a028f1 100644
--- a/kll/include/kll_helper_impl.hpp
+++ b/kll/include/kll_helper_impl.hpp
@@ -22,6 +22,8 @@
#include <algorithm>
+#include "common_defs.hpp"
+
namespace datasketches {
bool kll_helper::is_even(uint32_t value) {
diff --git a/req/include/req_common.hpp b/req/include/req_common.hpp
index 0e5b87a..31f5d44 100755
--- a/req/include/req_common.hpp
+++ b/req/include/req_common.hpp
@@ -28,10 +28,6 @@
namespace datasketches {
-// TODO: have a common random bit with KLL
-static std::independent_bits_engine<std::mt19937, 1, unsigned>
- req_random_bit(static_cast<unsigned>(std::chrono::system_clock::now().time_since_epoch().count()));
-
namespace req_constants {
static const uint16_t MIN_K = 4;
static const uint8_t INIT_NUM_SECTIONS = 3;
diff --git a/req/include/req_compactor_impl.hpp b/req/include/req_compactor_impl.hpp
index 221768c..c1cc11f 100755
--- a/req/include/req_compactor_impl.hpp
+++ b/req/include/req_compactor_impl.hpp
@@ -26,6 +26,7 @@
#include "count_zeros.hpp"
#include "conditional_forward.hpp"
+#include "common_defs.hpp"
#include <iomanip>
@@ -245,7 +246,7 @@ std::pair<uint32_t, uint32_t> req_compactor<T, C, A>::compact(req_compactor& nex
if (compaction_range.second - compaction_range.first < 2) throw std::logic_error("compaction range error");
if ((state_ & 1) == 1) { coin_ = !coin_; } // for odd flip coin;
- else { coin_ = req_random_bit(); } // random coin flip
+ else { coin_ = random_bit(); } // random coin flip
const auto num = (compaction_range.second - compaction_range.first) / 2;
next.ensure_space(num);
@@ -451,7 +452,7 @@ req_compactor<T, C, A>::req_compactor(bool hra, uint8_t lg_weight, bool sorted,
allocator_(allocator),
lg_weight_(lg_weight),
hra_(hra),
-coin_(req_random_bit()),
+coin_(random_bit()),
sorted_(sorted),
section_size_raw_(section_size_raw),
section_size_(nearest_even(section_size_raw)),
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org