@@ -49,7 +49,8 @@ Sketch::Sketch(vec_t vector_len, uint64_t seed, bool compressed, std::istream &b
4949 num_samples = _samples;
5050 cols_per_sample = _cols;
5151 num_columns = num_samples * cols_per_sample;
52- bkt_per_col = calc_bkt_per_col (vector_len);
52+ binary_in.read ((char *) &bkt_per_col, sizeof (size_t ));
53+ // bkt_per_col = calc_bkt_per_col(vector_len);
5354 num_buckets = num_columns * bkt_per_col + 1 ; // plus 1 for deterministic bucket
5455 // bucket_buffer = BucketBuffer(new BufferEntry[_cols * 2], _cols * 2);
5556 bucket_buffer = BucketBuffer ();
@@ -373,7 +374,8 @@ ExhaustiveSketchSample Sketch::exhaustive_sample() {
373374
374375
375376void Sketch::merge (const Sketch &other) {
376- if (other.calc_deepest_depth () > bkt_per_col) {
377+ unlikely_if (other.bkt_per_col > bkt_per_col && other.calc_deepest_depth () > bkt_per_col)
378+ {
377379 reallocate (other.calc_deepest_depth ());
378380 inject_buffer_buckets ();
379381 }
@@ -578,6 +580,7 @@ uint8_t Sketch::effective_depth() const
578580}
579581
580582void Sketch::compressed_serialize (std::ostream &binary_out) const {
583+ binary_out.write ((char *) &bkt_per_col, sizeof (size_t ));
581584#ifdef ROW_MAJOR_SKETCHES
582585 // write out max depth, nonempty flags, determinstic bucket, everything else
583586 // then all other buckets
@@ -607,6 +610,7 @@ void Sketch::compressed_serialize(std::ostream &binary_out) const {
607610}
608611
609612void Sketch::serialize (std::ostream &binary_out) const {
613+ binary_out.write ((char *) &bkt_per_col, sizeof (size_t ));
610614 // note that these will include the flag bits, if used.
611615 binary_out.write ((char *) buckets, bucket_array_bytes ());
612616}
0 commit comments