MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / compressible_log_data

Function compressible_log_data

nodedb-codec/src/lz4.rs:344–357  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

342
343 #[test]
344 fn compressible_log_data() {
345 // Highly repetitive log lines.
346 let line = "2024-01-15 ERROR database connection timeout host=db-prod-01 retry=3\n";
347 let data: Vec<u8> = line.as_bytes().repeat(500);
348 let encoded = encode(&data);
349 let decoded = decode(&encoded).unwrap();
350 assert_eq!(decoded, data);
351
352 let ratio = data.len() as f64 / encoded.len() as f64;
353 assert!(
354 ratio > 3.0,
355 "highly repetitive logs should compress >3x, got {ratio:.1}x"
356 );
357 }
358
359 #[test]
360 fn incompressible_data() {

Callers

nothing calls this directly

Calls 4

encodeFunction · 0.70
decodeFunction · 0.70
as_bytesMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected