diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index cbc0bed..49e0210 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -3,7 +3,6 @@ on: - push - pull_request - jobs: debian_x86: runs-on: ubuntu-22.04 @@ -29,3 +28,19 @@ jobs: run: cargo build - name: Run cargo test run: cargo test + windows_2019_x86: + runs-on: windows-2019 + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run cargo build + run: cargo build + windows_2022_x86: + runs-on: windows-2022 + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Run cargo build + run: cargo build diff --git a/build.rs b/build.rs index 6387b38..cfca0a5 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,6 @@ fn main() { let src = PathBuf::from("src"); let mut bridge = cxx_build::bridge(src.join("bridge.rs")); - assert!(bridge.is_flag_supported("-std=c++11").expect("supported")); bridge .files(&[ datasketches.join("cpc.cpp"), @@ -14,8 +13,12 @@ fn main() { datasketches.join("hh.cpp"), ]) .include(datasketches.join("common").join("include")) - .flag_if_supported("-std=c++11") .cpp_link_stdlib(None) - .static_flag(true) - .compile("libdatasketches.a"); + .static_flag(true); + + // MSVC doesn't plan to implement C++11 switch, because they use c++14 by default + #[cfg(not(target_env = "msvc"))] + bridge.flag_if_supported("-std=c++11"); + + bridge.compile("libdatasketches.a"); } diff --git a/datasketches-cpp/hh.cpp b/datasketches-cpp/hh.cpp index 452d8b9..8bcbadb 100644 --- a/datasketches-cpp/hh.cpp +++ b/datasketches-cpp/hh.cpp @@ -9,11 +9,13 @@ #include "fi/include/frequent_items_sketch.hpp" #include "hh.hpp" -std::unique_ptr> convert_to_thin(OpaqueHhSketch::hhsketch::vector_row v) { +std::unique_ptr> convert_to_thin(OpaqueHhSketch::hhsketch::vector_row v) +{ std::vector result(v.size()); - for (std::size_t i = 0; i < v.size(); ++i) { - auto& row = v[i]; - auto& target = result[i]; + for (std::size_t i = 0; i < v.size(); ++i) + { + auto &row = v[i]; + auto &target = result[i]; target.addr = row.get_item(); target.lb = row.get_lower_bound(); target.ub = row.get_upper_bound(); @@ -22,39 +24,47 @@ std::unique_ptr> convert_to_thin(OpaqueHhSketch: return std::unique_ptr>(ptr); } -std::unique_ptr> OpaqueHhSketch::estimate_no_fp() const { +std::unique_ptr> OpaqueHhSketch::estimate_no_fp() const +{ return convert_to_thin(this->inner_.get_frequent_items(datasketches::NO_FALSE_POSITIVES)); } -std::unique_ptr> OpaqueHhSketch::estimate_no_fn() const { +std::unique_ptr> OpaqueHhSketch::estimate_no_fn() const +{ return convert_to_thin(this->inner_.get_frequent_items(datasketches::NO_FALSE_NEGATIVES)); } -void OpaqueHhSketch::update(size_t value, uint64_t weight) { +void OpaqueHhSketch::update(size_t value, uint64_t weight) +{ this->inner_.update(value, weight); } -OpaqueHhSketch::OpaqueHhSketch(hhsketch&& sketch): - inner_{sketch} { +OpaqueHhSketch::OpaqueHhSketch(hhsketch &&sketch) : inner_{sketch} +{ } -std::unique_ptr> OpaqueHhSketch::state() const { +std::unique_ptr> OpaqueHhSketch::state() const +{ return convert_to_thin(this->inner_.get_frequent_items(datasketches::NO_FALSE_NEGATIVES, 0)); } -void OpaqueHhSketch::set_weights(uint64_t total_weight, uint64_t offset) { +void OpaqueHhSketch::set_weights(uint64_t total_weight, uint64_t offset) +{ this->inner_.set_weights(total_weight, offset); } -uint64_t OpaqueHhSketch::get_total_weight() const { +uint64_t OpaqueHhSketch::get_total_weight() const +{ return this->inner_.get_total_weight(); } -uint64_t OpaqueHhSketch::get_offset() const { +uint64_t OpaqueHhSketch::get_offset() const +{ return this->inner_.get_offset(); } -std::unique_ptr new_opaque_hh_sketch(uint8_t lg2_k, size_t hashset_addr) { +std::unique_ptr new_opaque_hh_sketch(uint8_t lg2_k, size_t hashset_addr) +{ OpaqueHhSketch::hhsketch sketch(lg2_k, hashset_addr); auto ptr = new OpaqueHhSketch(std::move(sketch)); return std::unique_ptr(ptr);