updated compress() to match the latest Java code
diff --git a/req/include/req_compactor.hpp b/req/include/req_compactor.hpp
index a55183e..3544c38 100755
--- a/req/include/req_compactor.hpp
+++ b/req/include/req_compactor.hpp
@@ -59,7 +59,7 @@
 
   void sort();
 
-  void compact(req_compactor& next);
+  std::pair<uint32_t, uint32_t> compact(req_compactor& next);
 
   /**
    * Computes size needed to serialize the current state of the compactor.
diff --git a/req/include/req_compactor_impl.hpp b/req/include/req_compactor_impl.hpp
index 841066c..e2f8ce8 100755
--- a/req/include/req_compactor_impl.hpp
+++ b/req/include/req_compactor_impl.hpp
@@ -232,7 +232,8 @@
 }
 
 template<typename T, bool H, typename C, typename A>
-void req_compactor<T, H, C, A>::compact(req_compactor& next) {
+std::pair<uint32_t, uint32_t> req_compactor<T, H, C, A>::compact(req_compactor& next) {
+  const uint32_t starting_nom_capacity = get_nom_capacity();
   // choose a part of the buffer to compact
   const uint32_t secs_to_compact = std::min(static_cast<uint32_t>(count_trailing_zeros_in_u32(~state_) + 1), static_cast<uint32_t>(num_sections_));
   auto compaction_range = compute_compaction_range(secs_to_compact);
@@ -253,6 +254,10 @@
 
   ++state_;
   ensure_enough_sections();
+  return std::pair<uint32_t, uint32_t>(
+    num,
+    get_nom_capacity() - starting_nom_capacity
+  );
 }
 
 template<typename T, bool H, typename C, typename A>
@@ -260,6 +265,7 @@
   const float ssr = section_size_raw_ / sqrt(2);
   const uint32_t ne = nearest_even(ssr);
   if (state_ >= static_cast<uint64_t>(1 << (num_sections_ - 1)) && ne >= req_constants::MIN_K) {
+    //std::cout << "lg weight: " << std::to_string(lg_weight_) << ", num sections: " << std::to_string(num_sections_) << ", new sec size: " << ssr << " -> " << ne << "\n";
     section_size_raw_ = ssr;
     section_size_ = ne;
     num_sections_ <<= 1;
diff --git a/req/include/req_sketch_impl.hpp b/req/include/req_sketch_impl.hpp
index 8ee16b4..a7e3020 100755
--- a/req/include/req_sketch_impl.hpp
+++ b/req/include/req_sketch_impl.hpp
@@ -505,12 +505,12 @@
       if (h + 1 >= get_num_levels()) { // at the top?
         grow(); // add a level, increases max_nom_size
       }
-      compactors_[h].compact(compactors_[h + 1]);
-      update_num_retained();
+      auto pair = compactors_[h].compact(compactors_[h + 1]);
+      num_retained_ -= pair.first;
+      max_nom_size_ += pair.second;
       if (num_retained_ < max_nom_size_) break;
     }
   }
-  update_max_nom_size();
 }
 
 template<typename T, bool H, typename C, typename S, typename A>