You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by GitBox <gi...@apache.org> on 2021/06/21 16:11:21 UTC
[GitHub] [datasketches-cpp] jmalkin commented on a change in pull request #222: CPC max serialized size bytes
jmalkin commented on a change in pull request #222:
URL: https://github.com/apache/datasketches-cpp/pull/222#discussion_r655521441
##########
File path: cpc/include/cpc_sketch_impl.hpp
##########
@@ -681,6 +679,46 @@ cpc_sketch_alloc<A> cpc_sketch_alloc<A>::deserialize(const void* bytes, size_t s
std::move(uncompressed.window), has_hip, kxp, hip_est_accum, seed);
}
+/*
+ * These empirical values for the 99.9th percentile of size in bytes were measured using 100,000
+ * trials. The value for each trial is the maximum of 5*16=80 measurements that were equally
+ * spaced over values of the quantity C/K between 3.0 and 8.0. This table does not include the
+ * worst-case space for the preamble, which is added by the function.
+ */
+static const size_t CPC_EMPIRICAL_MAX_SIZE_BYTES[] = {
+ 24, // lg_k = 4
+ 36, // lg_k = 5
+ 56, // lg_k = 6
+ 100, // lg_k = 7
+ 180, // lg_k = 8
+ 344, // lg_k = 9
+ 660, // lg_k = 10
+ 1292, // lg_k = 11
+ 2540, // lg_k = 12
+ 5020, // lg_k = 13
+ 9968, // lg_k = 14
+ 19836, // lg_k = 15
+ 39532, // lg_k = 16
+ 78880, // lg_k = 17
+ 157516, // lg_k = 18
+ 314656 // lg_k = 19
+};
+
+template<typename A>
+size_t cpc_sketch_alloc<A>::get_max_serialized_size_bytes(uint8_t lg_k) {
+ check_lg_k(lg_k);
+ if (lg_k <= 19) return CPC_EMPIRICAL_MAX_SIZE_BYTES[lg_k - 4] + 40;
Review comment:
Might be clearer to use CPC_MIN_LG_K instead of 4. And should we define a preamble size constant?
--
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.
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