You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by "jmalkin (via GitHub)" <gi...@apache.org> on 2023/03/01 19:57:25 UTC

[GitHub] [datasketches-cpp] jmalkin commented on a diff in pull request #325: Cpp countmin

jmalkin commented on code in PR #325:
URL: https://github.com/apache/datasketches-cpp/pull/325#discussion_r1122238713


##########
count/include/count_min_impl.hpp:
##########
@@ -0,0 +1,322 @@
+#ifndef COUNT_MIN_IMPL_HPP_
+#define COUNT_MIN_IMPL_HPP_
+
+#include "MurmurHash3.h"
+#include <random>
+
+namespace datasketches {
+
+template<typename W>
+count_min_sketch<W>::count_min_sketch(uint8_t num_hashes, uint32_t num_buckets, uint64_t seed):
+_num_hashes(num_hashes),
+_num_buckets(num_buckets),
+_sketch_array(num_hashes * num_buckets, 0),

Review Comment:
   This will attempt to initialize a gigantic array, only to later decide that it's too big and throw an exception. We can instead do an initial check here:
   `_sketch_array((num_hashes*num_buckets < 1<<30) ? num_hashes*num_buckets : 0, 0),`
   which should let us re-enabld the unit test check and also avoid a potential overallocaiton issue for end-users.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org