#pragma once #include #include #include #include #include "rust/cxx.h" #include "theta/include/theta_sketch.hpp" #include "theta/include/theta_union.hpp" #include "theta/include/theta_intersection.hpp" class OpaqueStaticThetaSketch; class OpaqueThetaSketch { public: double estimate() const; void update(rust::Slice buf); void update_u64(uint64_t value); std::unique_ptr as_static() const; private: OpaqueThetaSketch(); OpaqueThetaSketch(datasketches::update_theta_sketch&& theta); friend std::unique_ptr new_opaque_theta_sketch(); datasketches::update_theta_sketch inner_; }; std::unique_ptr new_opaque_theta_sketch(); class OpaqueStaticThetaSketch { public: double estimate() const; std::unique_ptr clone() const; void set_difference(const OpaqueStaticThetaSketch& other); std::unique_ptr> serialize() const; private: OpaqueStaticThetaSketch(const datasketches::compact_theta_sketch& theta); OpaqueStaticThetaSketch(datasketches::compact_theta_sketch&& theta); OpaqueStaticThetaSketch(std::istream& is); friend std::unique_ptr deserialize_opaque_static_theta_sketch(rust::Slice buf); friend class OpaqueThetaSketch; friend class OpaqueThetaUnion; friend class OpaqueThetaIntersection; datasketches::compact_theta_sketch inner_; }; std::unique_ptr deserialize_opaque_static_theta_sketch(rust::Slice buf); class OpaqueThetaUnion { public: std::unique_ptr sketch() const; void union_with(std::unique_ptr to_union); private: OpaqueThetaUnion(); datasketches::theta_union inner_; friend std::unique_ptr new_opaque_theta_union(); }; std::unique_ptr new_opaque_theta_union(); class OpaqueThetaIntersection { public: // Null if the intersection is over an empty collection, i.e., the sketch // implicitly represents the full universe of items. std::unique_ptr sketch() const; void intersect_with(std::unique_ptr to_intersect); private: OpaqueThetaIntersection(); datasketches::theta_intersection inner_; friend std::unique_ptr new_opaque_theta_intersection(); }; std::unique_ptr new_opaque_theta_intersection();