Skip to content

Commit

Permalink
added compressed theta sketches
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSaydakov committed Aug 26, 2023
1 parent c3f96ef commit c1509a4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions theta/test/theta_sketch_serialize_for_java.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ TEST_CASE("theta sketch generate", "[serialize_for_java]") {
}
}

TEST_CASE("theta sketch generate compressed", "[serialize_for_java]") {
const unsigned n_arr[] = {10, 100, 1000, 10000, 100000, 1000000};
for (const unsigned n: n_arr) {
auto sketch = update_theta_sketch::builder().build();
for (unsigned i = 0; i < n; ++i) sketch.update(i);
REQUIRE_FALSE(sketch.is_empty());
REQUIRE(sketch.get_estimate() == Approx(n).margin(n * 0.03));
std::ofstream os("theta_compressed_n" + std::to_string(n) + "_cpp.sk", std::ios::binary);
sketch.compact().serialize(os);
}
}

TEST_CASE("theta sketch generate non-empty no entries", "[serialize_for_java]") {
auto sketch = update_theta_sketch::builder().set_p(0.01).build();
sketch.update(1);
Expand Down

0 comments on commit c1509a4

Please sign in to comment.