apache-datasketches-sys 0.2.1

Raw cxx bridge to Apache DataSketches C++ (do not use directly; see apache-datasketches)
Documentation
#include "hll_union_shim.h"
#include "hll.rs.h" // generated by cxx from src/hll.rs (Task 7); provides the full TargetHllType enum definition

namespace apache_datasketches_rs {

HllUnionShim::HllUnionShim(uint8_t lg_max_k) : u_(lg_max_k) {}

void HllUnionShim::update_sketch(const HllSketchShim& sketch) {
  u_.update(sketch.inner());
}
void HllUnionShim::update_u64(uint64_t value) { u_.update(value); }
void HllUnionShim::update_i64(int64_t value) { u_.update(value); }
void HllUnionShim::update_f64(double value) { u_.update(value); }
void HllUnionShim::update_str(rust::Str value) {
  u_.update(std::string(value));
}
void HllUnionShim::update_bytes(rust::Slice<const uint8_t> value) {
  u_.update(value.data(), value.size());
}

std::unique_ptr<HllSketchShim> HllUnionShim::get_result(TargetHllType tgt_type) const {
  return std::make_unique<HllSketchShim>(u_.get_result(to_cpp_target_type(tgt_type)));
}

rust::Vec<uint8_t> HllUnionShim::serialize_compact(TargetHllType tgt_type) const {
  auto bytes = u_.get_result(to_cpp_target_type(tgt_type)).serialize_compact();
  rust::Vec<uint8_t> out;
  for (auto b : bytes) out.push_back(b);
  return out;
}

rust::Vec<uint8_t> HllUnionShim::serialize_updatable(TargetHllType tgt_type) const {
  auto bytes = u_.get_result(to_cpp_target_type(tgt_type)).serialize_updatable();
  rust::Vec<uint8_t> out;
  for (auto b : bytes) out.push_back(b);
  return out;
}

double HllUnionShim::get_estimate() const { return u_.get_estimate(); }
double HllUnionShim::get_lower_bound(uint8_t num_std_dev) const {
  return u_.get_lower_bound(num_std_dev);
}
double HllUnionShim::get_upper_bound(uint8_t num_std_dev) const {
  return u_.get_upper_bound(num_std_dev);
}
bool HllUnionShim::is_empty() const { return u_.is_empty(); }
void HllUnionShim::reset() { u_.reset(); }

std::unique_ptr<HllUnionShim> new_hll_union(uint8_t lg_max_k) {
  return std::make_unique<HllUnionShim>(lg_max_k);
}

} // namespace apache_datasketches_rs