Skip to content

Commit

Permalink
Merge pull request #436 from apache/fix_theta_compressed_stream
Browse files Browse the repository at this point in the history
cross-language test
  • Loading branch information
AlexanderSaydakov authored Jul 29, 2024
2 parents dba8394 + aac34bd commit a8348c2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions theta/test/theta_sketch_deserialize_from_java_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ TEST_CASE("theta sketch", "[serde_compat]") {
}
}

TEST_CASE("theta sketch compressed", "[serde_compat]") {
const unsigned n_arr[] = {10, 100, 1000, 10000, 100000, 1000000};
for (const unsigned n: n_arr) {
std::ifstream is;
is.exceptions(std::ios::failbit | std::ios::badbit);
is.open(testBinaryInputPath + "theta_compressed_n" + std::to_string(n) + "_java.sk", std::ios::binary);
const auto sketch = compact_theta_sketch::deserialize(is);
REQUIRE(sketch.is_estimation_mode() == (n > 1000));
REQUIRE(sketch.get_estimate() == Approx(n).margin(n * 0.03));
for (const auto hash: sketch) {
REQUIRE(hash < sketch.get_theta64());
}
REQUIRE(sketch.is_ordered());
REQUIRE(std::is_sorted(sketch.begin(), sketch.end()));
}
}

TEST_CASE("theta sketch non-empty no entries", "[serde_compat]") {
std::ifstream is;
is.exceptions(std::ios::failbit | std::ios::badbit);
Expand Down

0 comments on commit a8348c2

Please sign in to comment.