enforce max lgK
diff --git a/tuple/include/theta_update_sketch_base.hpp b/tuple/include/theta_update_sketch_base.hpp
index f81a2ba..425a8bd 100644
--- a/tuple/include/theta_update_sketch_base.hpp
+++ b/tuple/include/theta_update_sketch_base.hpp
@@ -94,6 +94,7 @@
public:
using resize_factor = theta_constants::resize_factor;
static const uint8_t MIN_LG_K = theta_constants::MIN_LG_K;
+ static const uint8_t MAX_LG_K = theta_constants::MAX_LG_K;
static const uint8_t DEFAULT_LG_K = 12;
static const resize_factor DEFAULT_RESIZE_FACTOR = resize_factor::X8;
diff --git a/tuple/include/theta_update_sketch_base_impl.hpp b/tuple/include/theta_update_sketch_base_impl.hpp
index d9198f4..be6c979 100644
--- a/tuple/include/theta_update_sketch_base_impl.hpp
+++ b/tuple/include/theta_update_sketch_base_impl.hpp
@@ -270,6 +270,9 @@
if (lg_k < MIN_LG_K) {
throw std::invalid_argument("lg_k must not be less than " + std::to_string(MIN_LG_K) + ": " + std::to_string(lg_k));
}
+ if (lg_k > MAX_LG_K) {
+ throw std::invalid_argument("lg_k must not be greater than " + std::to_string(MAX_LG_K) + ": " + std::to_string(lg_k));
+ }
lg_k_ = lg_k;
return static_cast<Derived&>(*this);
}