Skip to content

Commit a8348c2

Browse files
Merge pull request #436 from apache/fix_theta_compressed_stream
cross-language test
2 parents dba8394 + aac34bd commit a8348c2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

theta/test/theta_sketch_deserialize_from_java_test.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ TEST_CASE("theta sketch", "[serde_compat]") {
4545
}
4646
}
4747

48+
TEST_CASE("theta sketch compressed", "[serde_compat]") {
49+
const unsigned n_arr[] = {10, 100, 1000, 10000, 100000, 1000000};
50+
for (const unsigned n: n_arr) {
51+
std::ifstream is;
52+
is.exceptions(std::ios::failbit | std::ios::badbit);
53+
is.open(testBinaryInputPath + "theta_compressed_n" + std::to_string(n) + "_java.sk", std::ios::binary);
54+
const auto sketch = compact_theta_sketch::deserialize(is);
55+
REQUIRE(sketch.is_estimation_mode() == (n > 1000));
56+
REQUIRE(sketch.get_estimate() == Approx(n).margin(n * 0.03));
57+
for (const auto hash: sketch) {
58+
REQUIRE(hash < sketch.get_theta64());
59+
}
60+
REQUIRE(sketch.is_ordered());
61+
REQUIRE(std::is_sorted(sketch.begin(), sketch.end()));
62+
}
63+
}
64+
4865
TEST_CASE("theta sketch non-empty no entries", "[serde_compat]") {
4966
std::ifstream is;
5067
is.exceptions(std::ios::failbit | std::ios::badbit);

0 commit comments

Comments
 (0)