Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support building on Windows #2

Open
wants to merge 4 commits into
base: cubestore
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
- push
- pull_request


jobs:
debian_x86:
runs-on: ubuntu-22.04
Expand All @@ -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
11 changes: 7 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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");
}
38 changes: 24 additions & 14 deletions datasketches-cpp/hh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
#include "fi/include/frequent_items_sketch.hpp"
#include "hh.hpp"

std::unique_ptr<std::vector<ThinHeavyHitterRow>> convert_to_thin(OpaqueHhSketch::hhsketch::vector_row v) {
std::unique_ptr<std::vector<ThinHeavyHitterRow>> convert_to_thin(OpaqueHhSketch::hhsketch::vector_row v)
{
std::vector<ThinHeavyHitterRow> 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();
Expand All @@ -22,39 +24,47 @@ std::unique_ptr<std::vector<ThinHeavyHitterRow>> convert_to_thin(OpaqueHhSketch:
return std::unique_ptr<std::vector<ThinHeavyHitterRow>>(ptr);
}

std::unique_ptr<std::vector<ThinHeavyHitterRow>> OpaqueHhSketch::estimate_no_fp() const {
std::unique_ptr<std::vector<ThinHeavyHitterRow>> OpaqueHhSketch::estimate_no_fp() const
{
return convert_to_thin(this->inner_.get_frequent_items(datasketches::NO_FALSE_POSITIVES));
}

std::unique_ptr<std::vector<ThinHeavyHitterRow>> OpaqueHhSketch::estimate_no_fn() const {
std::unique_ptr<std::vector<ThinHeavyHitterRow>> 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<std::vector<ThinHeavyHitterRow>> OpaqueHhSketch::state() const {
std::unique_ptr<std::vector<ThinHeavyHitterRow>> 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<OpaqueHhSketch> new_opaque_hh_sketch(uint8_t lg2_k, size_t hashset_addr) {
std::unique_ptr<OpaqueHhSketch> 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<OpaqueHhSketch>(ptr);
Expand Down
Loading