This is an automated email from the ASF dual-hosted git repository.
tisonkun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 6d8b342 test: bump TCK revision and cover remaining peer snapshots
(#384)
6d8b342 is described below
commit 6d8b3420240891f06f0315f5a448183db91a0552
Author: tison <[email protected]>
AuthorDate: Wed Nov 18 17:47:47 2026 +0800
test: bump TCK revision and cover remaining peer snapshots (#384)
---
tests-integration/tests/serde_tests/bloom.rs | 79 ++++++-
tests-integration/tests/serde_tests/countmin.rs | 101 ++++++++-
tests-integration/tests/serde_tests/cpc.rs | 47 +++--
tests-integration/tests/serde_tests/frequencies.rs | 27 +++
tests-integration/tests/serde_tests/hll.rs | 51 +++++
tests-integration/tests/serde_tests/req.rs | 230 +++++++++++++--------
xtask/src/prepare_testdata.rs | 2 +-
7 files changed, 419 insertions(+), 118 deletions(-)
diff --git a/tests-integration/tests/serde_tests/bloom.rs
b/tests-integration/tests/serde_tests/bloom.rs
index 3120b8d..9556420 100644
--- a/tests-integration/tests/serde_tests/bloom.rs
+++ b/tests-integration/tests/serde_tests/bloom.rs
@@ -22,6 +22,7 @@ use datasketches::bloom::BloomFilter;
use datasketches::bloom::BloomFilterBuilder;
use datasketches::error::ErrorKind;
use datasketches::hash::value::canonical_float;
+use datasketches::hash::value::raw_bytes;
use googletest::assert_that;
use googletest::prelude::gt;
@@ -54,7 +55,7 @@ fn test_bloom_filter_file(path: PathBuf, expected_num_items:
u64, expected_num_h
path.display()
);
- // TCK fixtures insert integers 0..n/10. Bound the sample for large
fixtures.
+ // TCK fixtures insert integers 0..n/10 and, when non-empty, canonical NaN.
for item in 0..(expected_num_items / 10).min(100) {
assert!(
filter1.contains(item),
@@ -62,6 +63,13 @@ fn test_bloom_filter_file(path: PathBuf, expected_num_items:
u64, expected_num_h
path.display()
);
}
+ if expected_num_items > 0 {
+ assert!(
+ filter1.contains(canonical_float::from_f64(f64::NAN)),
+ "Missing canonical NaN in {}",
+ path.display()
+ );
+ }
let serialized_bytes = filter1.serialize();
let filter2 =
BloomFilter::deserialize(&serialized_bytes).unwrap_or_else(|err| {
@@ -125,6 +133,8 @@ fn test_go_compatibility() {
(10_000, 5),
(2_000_000, 3),
(2_000_000, 5),
+ (30_000_000, 3),
+ (30_000_000, 5),
] {
let filename = format!("bf_n{n}_h{num_hashes}_go.sk");
let path = serialization_test_data("go_generated_files", &filename);
@@ -132,6 +142,73 @@ fn test_go_compatibility() {
}
}
+#[test]
+fn test_go_typed_compatibility() {
+ let load_go_filter = |filename: &str| {
+ let path = serialization_test_data("go_generated_files", filename);
+ let bytes = fs::read(&path).unwrap();
+ let filter = BloomFilter::deserialize(&bytes).unwrap();
+ assert_eq!(
+ filter.capacity(),
+ 10_000_u64.next_multiple_of(64),
+ "{filename}"
+ );
+ assert_eq!(filter.num_hashes(), 3, "{filename}");
+ assert!(!filter.is_empty(), "{filename}");
+ assert_eq!(filter.serialize(), bytes, "{filename}");
+ filter
+ };
+
+ let str_filter = load_go_filter("bf_string_n10000_h3_go.sk");
+ for i in 0..1000 {
+ let item = i.to_string();
+ assert!(
+ str_filter.contains(raw_bytes::from_str(&item)),
+ "missing string {item}"
+ );
+ }
+
+ let double_filter = load_go_filter("bf_double_n10000_h3_go.sk");
+ for i in 0..1000 {
+ assert!(
+ double_filter.contains(canonical_float::from_f64(i as f64)),
+ "missing double {i}"
+ );
+ }
+
+ let long_array_filter = load_go_filter("bf_long_array_n10000_h3_go.sk");
+ for i in 0..1000_i64 {
+ let mut buf = [0_u8; 16];
+ buf[..8].copy_from_slice(&i.to_le_bytes());
+ buf[8..].copy_from_slice(&i.to_le_bytes());
+ assert!(
+ long_array_filter.contains(raw_bytes::from_slice(&buf)),
+ "missing long array {i}"
+ );
+ }
+
+ let double_array_filter =
load_go_filter("bf_double_array_n10000_h3_go.sk");
+ for i in 0..1000 {
+ let mut buf = [0_u8; 16];
+ let bits = (i as f64).to_bits().to_le_bytes();
+ buf[..8].copy_from_slice(&bits);
+ buf[8..].copy_from_slice(&bits);
+ assert!(
+ double_array_filter.contains(raw_bytes::from_slice(&buf)),
+ "missing double array {i}"
+ );
+ }
+
+ let byte_array_filter = load_go_filter("bf_byte_array_n10000_h3_go.sk");
+ for i in 0..1000_u32 {
+ let b = (i % 256) as u8;
+ assert!(
+ byte_array_filter.contains(raw_bytes::from_slice(&[b, b, b, b])),
+ "missing byte array {i}"
+ );
+ }
+}
+
#[test]
fn test_rust_compatibility() {
for (n, num_hashes) in [
diff --git a/tests-integration/tests/serde_tests/countmin.rs
b/tests-integration/tests/serde_tests/countmin.rs
index 512e5f0..07d6659 100644
--- a/tests-integration/tests/serde_tests/countmin.rs
+++ b/tests-integration/tests/serde_tests/countmin.rs
@@ -280,16 +280,17 @@ fn rejects_weights_that_cannot_bound_counter_arithmetic()
{
}
// This helper validates binary format compatibility (deserialize + byte
round-trip) for
-// version 1 datasketches-cpp CountMin snapshots. It intentionally does not
assert estimate
-// equivalence because version 1 row-seed derivation differs across
implementations.
-fn assert_cpp_snapshot(
+// version 1 datasketches-cpp and datasketches-go CountMin snapshots. It
intentionally does not
+// assert estimate equivalence because version 1 row-seed derivation differs
across implementations.
+fn assert_v1_snapshot(
+ dir: &str,
filename: &str,
seed: u64,
expected_num_hashes: u8,
expected_num_buckets: u32,
expected_total_weight: u64,
) {
- let path = serialization_test_data("cpp_generated_files", filename);
+ let path = serialization_test_data(dir, filename);
let bytes = fs::read(&path).unwrap();
let sketch = CountMinSketch::<u64>::deserialize_with_seed(&bytes,
seed).unwrap();
@@ -306,12 +307,47 @@ fn assert_cpp_snapshot(
#[test]
fn test_deserialize_cpp_empty_snapshot() {
- assert_cpp_snapshot("count_min_empty_cpp.sk", 9001, 1, 5, 0);
+ assert_v1_snapshot(
+ "cpp_generated_files",
+ "count_min_empty_cpp.sk",
+ 9001,
+ 1,
+ 5,
+ 0,
+ );
}
#[test]
fn test_deserialize_cpp_non_empty_snapshot() {
- assert_cpp_snapshot("count_min_non_empty_cpp.sk", 9001, 3, 1024, 2850);
+ assert_v1_snapshot(
+ "cpp_generated_files",
+ "count_min_non_empty_cpp.sk",
+ 9001,
+ 3,
+ 1024,
+ 2850,
+ );
+}
+
+#[test]
+fn test_deserialize_go_empty_snapshot() {
+ assert_v1_snapshot("go_generated_files", "count_min_empty_go.sk", 9001, 1,
5, 0);
+}
+
+#[test]
+fn test_deserialize_go_non_empty_snapshot() {
+ assert_v1_snapshot(
+ "go_generated_files",
+ "count_min_non_empty_go.sk",
+ 9001,
+ 3,
+ 1024,
+ 2850,
+ );
+ let path = serialization_test_data("go_generated_files",
"count_min_non_empty_go.sk");
+ let bytes = fs::read(&path).unwrap();
+ let err = CountMinSketch::<u64>::deserialize_with_seed(&bytes,
9000).unwrap_err();
+ assert_that!(err.message(), contains_substring("incompatible seed hash"));
}
#[test]
@@ -335,10 +371,10 @@ fn zero_seed_hash_uses_the_callers_error_kind() {
assert_eq!(deserialization_error.kind(), ErrorKind::InvalidData);
}
-fn assert_rust_v2_snapshot(filename: &str, seed: u64, n: u64) {
+fn assert_v2_snapshot(dir: &str, filename: &str, seed: u64, n: u64) {
const DEFAULT_SEED: u64 = 9001;
- let path = serialization_test_data("rust_generated_files", filename);
+ let path = serialization_test_data(dir, filename);
let bytes = fs::read(&path).unwrap();
assert_eq!(bytes[1], 2, "expected v2 serial version in {filename}");
@@ -395,11 +431,56 @@ fn assert_rust_v2_snapshot(filename: &str, seed: u64, n:
u64) {
);
}
+#[test]
+fn test_deserialize_java_v2_snapshots() {
+ for n in [0, 1, 10, 100, 1000, 10_000] {
+ let java_filename = format!("count_min_v2_n{n}_java.sk");
+ let rust_filename = format!("count_min_v2_n{n}_rust.sk");
+ assert_v2_snapshot("java_generated_files", &java_filename, 9001, n);
+ assert_eq!(
+ fs::read(serialization_test_data(
+ "java_generated_files",
+ &java_filename
+ ))
+ .unwrap(),
+ fs::read(serialization_test_data(
+ "rust_generated_files",
+ &rust_filename
+ ))
+ .unwrap(),
+ "{java_filename}"
+ );
+ }
+ assert_v2_snapshot(
+ "java_generated_files",
+ "count_min_v2_seed42_n1000_java.sk",
+ 42,
+ 1000,
+ );
+ assert_eq!(
+ fs::read(serialization_test_data(
+ "java_generated_files",
+ "count_min_v2_seed42_n1000_java.sk"
+ ))
+ .unwrap(),
+ fs::read(serialization_test_data(
+ "rust_generated_files",
+ "count_min_v2_seed42_n1000_rust.sk"
+ ))
+ .unwrap(),
+ );
+}
+
#[test]
fn test_deserialize_rust_v2_snapshots() {
for n in [0, 1, 10, 100, 1000, 10_000] {
let filename = format!("count_min_v2_n{n}_rust.sk");
- assert_rust_v2_snapshot(&filename, 9001, n);
+ assert_v2_snapshot("rust_generated_files", &filename, 9001, n);
}
- assert_rust_v2_snapshot("count_min_v2_seed42_n1000_rust.sk", 42, 1000);
+ assert_v2_snapshot(
+ "rust_generated_files",
+ "count_min_v2_seed42_n1000_rust.sk",
+ 42,
+ 1000,
+ );
}
diff --git a/tests-integration/tests/serde_tests/cpc.rs
b/tests-integration/tests/serde_tests/cpc.rs
index 88de077..9e868b4 100644
--- a/tests-integration/tests/serde_tests/cpc.rs
+++ b/tests-integration/tests/serde_tests/cpc.rs
@@ -131,6 +131,27 @@ fn test_sketch_replay(path: &Path, sketch: CpcSketch,
inputs: impl Iterator<Item
);
}
+fn assert_negative_one_file(dir: &str, filename: &str) -> Vec<u8> {
+ let path = serialization_test_data(dir, filename);
+ let bytes = fs::read(&path).unwrap();
+ let mut sketch = CpcSketch::deserialize(&bytes).unwrap();
+ assert_eq!(sketch.lg_k(), 11, "{filename}");
+ assert!(!sketch.is_empty(), "{filename}");
+ let initial_estimate = sketch.estimate();
+ assert_that!(initial_estimate, near(1.0, 0.02));
+ assert_eq!(sketch.serialize(), bytes, "{filename}");
+
+ let wrapper = CpcWrapper::new(&bytes).unwrap();
+ assert_eq!(wrapper.estimate(), initial_estimate, "{filename}");
+
+ sketch.update(sign_extend::from_i8(-1));
+ sketch.update(sign_extend::from_i16(-1));
+ sketch.update(sign_extend::from_i32(-1));
+ sketch.update(-1_i64);
+ assert_eq!(sketch.estimate(), initial_estimate, "{filename}");
+ bytes
+}
+
#[test]
fn test_java_compatibility() {
let test_cases = [0, 100, 200, 2000, 20000];
@@ -141,6 +162,14 @@ fn test_java_compatibility() {
let sketch = test_sketch_file(&path, n);
test_sketch_replay(&path, sketch, 0..n);
}
+
+ let java_neg = assert_negative_one_file("java_generated_files",
"cpc_negative_one_java.sk");
+ let rust_neg = fs::read(serialization_test_data(
+ "rust_generated_files",
+ "cpc_negative_one_rust.sk",
+ ))
+ .unwrap();
+ assert_eq!(java_neg, rust_neg);
}
#[test]
@@ -180,21 +209,5 @@ fn test_rust_compatibility() {
test_sketch_replay(&path, sketch, 0..n);
}
- let neg_path = serialization_test_data("rust_generated_files",
"cpc_negative_one_rust.sk");
- let neg_bytes = fs::read(&neg_path).unwrap();
- let mut neg_sketch = CpcSketch::deserialize(&neg_bytes).unwrap();
- assert_eq!(neg_sketch.lg_k(), 11);
- assert!(!neg_sketch.is_empty());
- let initial_estimate = neg_sketch.estimate();
- assert_that!(initial_estimate, near(1.0, 0.02));
- assert_eq!(neg_sketch.serialize(), neg_bytes);
-
- let wrapper = CpcWrapper::new(&neg_bytes).unwrap();
- assert_eq!(wrapper.estimate(), initial_estimate);
-
- neg_sketch.update(sign_extend::from_i8(-1));
- neg_sketch.update(sign_extend::from_i16(-1));
- neg_sketch.update(sign_extend::from_i32(-1));
- neg_sketch.update(-1_i64);
- assert_eq!(neg_sketch.estimate(), initial_estimate);
+ assert_negative_one_file("rust_generated_files",
"cpc_negative_one_rust.sk");
}
diff --git a/tests-integration/tests/serde_tests/frequencies.rs
b/tests-integration/tests/serde_tests/frequencies.rs
index 7617865..3750b92 100644
--- a/tests-integration/tests/serde_tests/frequencies.rs
+++ b/tests-integration/tests/serde_tests/frequencies.rs
@@ -190,6 +190,16 @@ fn test_java_frequent_strings_purged() {
check_purged_compatibility::<String>("java_generated_files",
"frequent_string_purged_java.sk");
}
+#[test]
+fn test_go_frequent_longs_purged() {
+ check_purged_compatibility::<i64>("go_generated_files",
"frequent_long_purged_go.sk");
+}
+
+#[test]
+fn test_go_frequent_strings_purged() {
+ check_purged_compatibility::<String>("go_generated_files",
"frequent_string_purged_go.sk");
+}
+
#[test]
fn test_rust_frequent_longs_purged() {
check_purged_compatibility::<i64>("rust_generated_files",
"frequent_long_purged_rust.sk");
@@ -308,6 +318,23 @@ fn test_java_frequent_longs_compatibility() {
}
}
+#[test]
+fn test_java_frequent_strings_compatibility() {
+ for n in [0, 1, 10, 100, 1000, 10000, 100000, 1000000] {
+ let filename = format!("frequent_string_n{n}_java.sk");
+ let path = serialization_test_data("java_generated_files", &filename);
+ let bytes = fs::read(&path).unwrap();
+ let sketch =
FrequentItemsSketch::<String>::deserialize(&bytes).unwrap();
+ assert_eq!(sketch.is_empty(), n == 0);
+ if n > 10 {
+ assert_that!(sketch.maximum_error(), gt(0));
+ } else {
+ assert_eq!(sketch.maximum_error(), 0);
+ }
+ assert_eq!(sketch.total_weight(), n);
+ }
+}
+
#[test]
fn test_java_frequent_strings_ascii() {
let path = serialization_test_data("java_generated_files",
"frequent_string_ascii_java.sk");
diff --git a/tests-integration/tests/serde_tests/hll.rs
b/tests-integration/tests/serde_tests/hll.rs
index b0b0a8b..87b701f 100644
--- a/tests-integration/tests/serde_tests/hll.rs
+++ b/tests-integration/tests/serde_tests/hll.rs
@@ -539,6 +539,57 @@ fn test_java_hll8_compatibility() {
}
}
+#[test]
+fn test_java_hll_union_compatibility() {
+ for (type_name, expected_type) in [
+ ("hll4", HllType::Hll4),
+ ("hll6", HllType::Hll6),
+ ("hll8", HllType::Hll8),
+ ] {
+ let compact_name = format!("{type_name}_union_java.sk");
+ let compact_path = serialization_test_data("java_generated_files",
&compact_name);
+ let compact_bytes = fs::read(&compact_path).unwrap();
+ assert_ne!(compact_bytes[5] & 0x08, 0, "{compact_name}");
+
+ let rust_name = format!("{type_name}_union_rust.sk");
+ let rust_bytes =
+ fs::read(serialization_test_data("rust_generated_files",
&rust_name)).unwrap();
+ assert_eq!(compact_bytes, rust_bytes, "{compact_name}");
+
+ let compact_sketch = HllSketch::deserialize(&compact_bytes).unwrap();
+ assert_eq!(compact_sketch.lg_config_k(), 12, "{compact_name}");
+ assert_eq!(
+ compact_sketch.target_type(),
+ expected_type,
+ "{compact_name}"
+ );
+ assert!(!compact_sketch.is_empty(), "{compact_name}");
+ test_sketch_file(compact_path, 6000, 12);
+
+ let upd_name = format!("{type_name}_unionupd_java.sk");
+ let upd_path = serialization_test_data("java_generated_files",
&upd_name);
+ let upd_bytes = fs::read(&upd_path).unwrap();
+ assert_eq!(upd_bytes[5] & 0x08, 0, "{upd_name}");
+
+ let upd_sketch = HllSketch::deserialize(&upd_bytes).unwrap();
+ assert_eq!(upd_sketch.lg_config_k(), 12, "{upd_name}");
+ assert_eq!(upd_sketch.target_type(), expected_type, "{upd_name}");
+ assert!(!upd_sketch.is_empty(), "{upd_name}");
+ assert_hll_sketches_eq(&upd_sketch, &compact_sketch, &upd_name);
+ assert_eq!(
+ upd_sketch.estimate(),
+ compact_sketch.estimate(),
+ "{upd_name}"
+ );
+ assert_eq!(
+ upd_sketch.composite_estimate(),
+ compact_sketch.composite_estimate(),
+ "{upd_name}"
+ );
+ test_sketch_file(upd_path, 6000, 12);
+ }
+}
+
#[test]
fn test_cpp_hll4_compatibility() {
let test_cases = [0, 1, 10, 100, 1000, 10000, 100000, 1000000];
diff --git a/tests-integration/tests/serde_tests/req.rs
b/tests-integration/tests/serde_tests/req.rs
index 0ff5577..c76b7f6 100644
--- a/tests-integration/tests/serde_tests/req.rs
+++ b/tests-integration/tests/serde_tests/req.rs
@@ -544,6 +544,95 @@ fn validate_cross_language_fixture(path: PathBuf,
expected_n: u64) {
);
}
+fn validate_negative_fixture(dir: &str, filename: &str, m: u64) {
+ let path = serialization_test_data(dir, filename);
+ let bytes = fs::read(&path).unwrap();
+ let sketch = ReqSketch::<ReqF32>::deserialize(&bytes).unwrap();
+ let min = req_f32(-(m as f32));
+ let max = req_f32(-1.0);
+ assert_eq!(sketch.k(), 12, "{filename}");
+ assert_eq!(sketch.rank_accuracy(), RankAccuracy::HighRank, "{filename}");
+ assert!(!sketch.is_empty(), "{filename}");
+ assert!(!sketch.is_estimation_mode(), "{filename}");
+ assert_eq!(sketch.total_weight(), m, "{filename}");
+ assert_eq!(sketch.min_item(), Some(&min), "{filename}");
+ assert_eq!(sketch.max_item(), Some(&max), "{filename}");
+ assert_eq!(
+ sketch.quantile(0.0, SearchCriteria::Inclusive).unwrap(),
+ Some(min),
+ "{filename}"
+ );
+ assert_eq!(
+ sketch.quantile(1.0, SearchCriteria::Inclusive).unwrap(),
+ Some(max),
+ "{filename}"
+ );
+ assert_eq!(
+ sketch.rank(&min, SearchCriteria::Exclusive),
+ Some(0.0),
+ "{filename}"
+ );
+ assert_eq!(
+ sketch.rank(&min, SearchCriteria::Inclusive),
+ Some(1.0 / m as f64),
+ "{filename}"
+ );
+ assert_eq!(
+ sketch.rank(&max, SearchCriteria::Inclusive),
+ Some(1.0),
+ "{filename}"
+ );
+ assert_eq!(sketch.serialize(), bytes, "{filename}");
+}
+
+fn validate_mixed_fixture(dir: &str, filename: &str, m: u64) {
+ let path = serialization_test_data(dir, filename);
+ let bytes = fs::read(&path).unwrap();
+ let sketch = ReqSketch::<ReqF32>::deserialize(&bytes).unwrap();
+ let expected_n = 2 * m + 1;
+ let min = req_f32(-(m as f32));
+ let zero = req_f32(0.0);
+ let max = req_f32(m as f32);
+ assert_eq!(sketch.k(), 12, "{filename}");
+ assert_eq!(sketch.rank_accuracy(), RankAccuracy::HighRank, "{filename}");
+ assert!(!sketch.is_empty(), "{filename}");
+ assert!(!sketch.is_estimation_mode(), "{filename}");
+ assert_eq!(sketch.total_weight(), expected_n, "{filename}");
+ assert_eq!(sketch.min_item(), Some(&min), "{filename}");
+ assert_eq!(sketch.max_item(), Some(&max), "{filename}");
+ assert_eq!(
+ sketch.quantile(0.0, SearchCriteria::Inclusive).unwrap(),
+ Some(min),
+ "{filename}"
+ );
+ assert_eq!(
+ sketch.quantile(0.5, SearchCriteria::Inclusive).unwrap(),
+ Some(zero),
+ "{filename}"
+ );
+ assert_eq!(
+ sketch.quantile(1.0, SearchCriteria::Inclusive).unwrap(),
+ Some(max),
+ "{filename}"
+ );
+ assert_eq!(
+ sketch.rank(&zero, SearchCriteria::Exclusive),
+ Some(m as f64 / expected_n as f64),
+ "{filename}"
+ );
+ assert_eq!(
+ sketch.rank(&zero, SearchCriteria::Inclusive),
+ Some((m + 1) as f64 / expected_n as f64),
+ "{filename}"
+ );
+ assert_eq!(
+ sketch.rank(&max, SearchCriteria::Inclusive),
+ Some(1.0),
+ "{filename}"
+ );
+ assert_eq!(sketch.serialize(), bytes, "{filename}");
+}
+
#[test]
fn cpp_compatibility() {
for n in [0u64, 1, 10, 100, 1000, 10000, 100000, 1000000] {
@@ -551,6 +640,18 @@ fn cpp_compatibility() {
serialization_test_data("cpp_generated_files",
&format!("req_float_n{n}_cpp.sk"));
validate_cross_language_fixture(path, n);
}
+ for m in [1u64, 10] {
+ validate_negative_fixture(
+ "cpp_generated_files",
+ &format!("req_float_negative_n{m}_cpp.sk"),
+ m,
+ );
+ validate_mixed_fixture(
+ "cpp_generated_files",
+ &format!("req_float_mixed_n{m}_cpp.sk"),
+ m,
+ );
+ }
}
#[test]
@@ -560,6 +661,38 @@ fn java_compatibility() {
serialization_test_data("java_generated_files",
&format!("req_float_n{n}_java.sk"));
validate_cross_language_fixture(path, n);
}
+ for m in [1u64, 10] {
+ validate_negative_fixture(
+ "java_generated_files",
+ &format!("req_float_negative_n{m}_java.sk"),
+ m,
+ );
+ validate_mixed_fixture(
+ "java_generated_files",
+ &format!("req_float_mixed_n{m}_java.sk"),
+ m,
+ );
+ }
+}
+
+#[test]
+fn go_compatibility() {
+ for n in [0u64, 1, 10, 100, 1000, 10000, 100000, 1000000] {
+ let path = serialization_test_data("go_generated_files",
&format!("req_float_n{n}_go.sk"));
+ validate_cross_language_fixture(path, n);
+ }
+ for m in [1u64, 10] {
+ validate_negative_fixture(
+ "go_generated_files",
+ &format!("req_float_negative_n{m}_go.sk"),
+ m,
+ );
+ validate_mixed_fixture(
+ "go_generated_files",
+ &format!("req_float_mixed_n{m}_go.sk"),
+ m,
+ );
+ }
}
#[test]
@@ -569,97 +702,16 @@ fn rust_compatibility() {
serialization_test_data("rust_generated_files",
&format!("req_float_n{n}_rust.sk"));
validate_cross_language_fixture(path, n);
}
-
for m in [1u64, 10] {
- let neg_name = format!("req_float_negative_n{m}_rust.sk");
- let neg_path = serialization_test_data("rust_generated_files",
&neg_name);
- let neg_bytes = fs::read(&neg_path).unwrap();
- let neg = ReqSketch::<ReqF32>::deserialize(&neg_bytes).unwrap();
- let neg_min = req_f32(-(m as f32));
- let neg_max = req_f32(-1.0);
- assert_eq!(neg.k(), 12, "{neg_name}");
- assert_eq!(neg.rank_accuracy(), RankAccuracy::HighRank, "{neg_name}");
- assert!(!neg.is_empty(), "{neg_name}");
- assert!(!neg.is_estimation_mode(), "{neg_name}");
- assert_eq!(neg.total_weight(), m, "{neg_name}");
- assert_eq!(neg.min_item(), Some(&neg_min), "{neg_name}");
- assert_eq!(neg.max_item(), Some(&neg_max), "{neg_name}");
- assert_eq!(
- neg.quantile(0.0, SearchCriteria::Inclusive).unwrap(),
- Some(neg_min),
- "{neg_name}"
- );
- assert_eq!(
- neg.quantile(1.0, SearchCriteria::Inclusive).unwrap(),
- Some(neg_max),
- "{neg_name}"
- );
- assert_eq!(
- neg.rank(&neg_min, SearchCriteria::Exclusive),
- Some(0.0),
- "{neg_name}"
- );
- assert_eq!(
- neg.rank(&neg_min, SearchCriteria::Inclusive),
- Some(1.0 / m as f64),
- "{neg_name}"
- );
- assert_eq!(
- neg.rank(&neg_max, SearchCriteria::Inclusive),
- Some(1.0),
- "{neg_name}"
- );
- assert_eq!(neg.serialize(), neg_bytes, "{neg_name}");
-
- let mixed_name = format!("req_float_mixed_n{m}_rust.sk");
- let mixed_path = serialization_test_data("rust_generated_files",
&mixed_name);
- let mixed_bytes = fs::read(&mixed_path).unwrap();
- let mixed = ReqSketch::<ReqF32>::deserialize(&mixed_bytes).unwrap();
- let expected_n = 2 * m + 1;
- let mixed_min = req_f32(-(m as f32));
- let zero = req_f32(0.0);
- let mixed_max = req_f32(m as f32);
- assert_eq!(mixed.k(), 12, "{mixed_name}");
- assert_eq!(
- mixed.rank_accuracy(),
- RankAccuracy::HighRank,
- "{mixed_name}"
- );
- assert!(!mixed.is_empty(), "{mixed_name}");
- assert!(!mixed.is_estimation_mode(), "{mixed_name}");
- assert_eq!(mixed.total_weight(), expected_n, "{mixed_name}");
- assert_eq!(mixed.min_item(), Some(&mixed_min), "{mixed_name}");
- assert_eq!(mixed.max_item(), Some(&mixed_max), "{mixed_name}");
- assert_eq!(
- mixed.quantile(0.0, SearchCriteria::Inclusive).unwrap(),
- Some(mixed_min),
- "{mixed_name}"
- );
- assert_eq!(
- mixed.quantile(0.5, SearchCriteria::Inclusive).unwrap(),
- Some(zero),
- "{mixed_name}"
- );
- assert_eq!(
- mixed.quantile(1.0, SearchCriteria::Inclusive).unwrap(),
- Some(mixed_max),
- "{mixed_name}"
- );
- assert_eq!(
- mixed.rank(&zero, SearchCriteria::Exclusive),
- Some(m as f64 / expected_n as f64),
- "{mixed_name}"
- );
- assert_eq!(
- mixed.rank(&zero, SearchCriteria::Inclusive),
- Some((m + 1) as f64 / expected_n as f64),
- "{mixed_name}"
+ validate_negative_fixture(
+ "rust_generated_files",
+ &format!("req_float_negative_n{m}_rust.sk"),
+ m,
);
- assert_eq!(
- mixed.rank(&mixed_max, SearchCriteria::Inclusive),
- Some(1.0),
- "{mixed_name}"
+ validate_mixed_fixture(
+ "rust_generated_files",
+ &format!("req_float_mixed_n{m}_rust.sk"),
+ m,
);
- assert_eq!(mixed.serialize(), mixed_bytes, "{mixed_name}");
}
}
diff --git a/xtask/src/prepare_testdata.rs b/xtask/src/prepare_testdata.rs
index 87038ca..deeb43b 100644
--- a/xtask/src/prepare_testdata.rs
+++ b/xtask/src/prepare_testdata.rs
@@ -90,7 +90,7 @@ impl CommandPrepareTestData {
}
fn prepare_remote(serde_tests: &Path, languages: &[&'static str]) ->
Result<()> {
- const REVISION: &str = "8193bab45ca5da3b513ea43fb5793e7e5b4da548";
+ const REVISION: &str = "78c63c3ef89f85f68d60b0ff00a4e3cadf411c98";
let archive_url =
format!("https://api.github.com/repos/apache/datasketches-tck/tarball/{REVISION}");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]