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

Function large_data_multiple_blocks

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

Source from the content-addressed store, hash-verified

291
292 #[test]
293 fn large_data_multiple_blocks() {
294 // Generate ~40KB of log-like data (10 blocks of 4KB each).
295 let mut data = Vec::new();
296 for i in 0..1000 {
297 let line = format!(
298 "2024-01-15T10:30:{:02}.000Z INFO server.handler request_id={} method=GET path=/api/v1/metrics status=200 duration_ms={}\n",
299 i % 60,
300 10000 + i,
301 i * 3 + 1
302 );
303 data.extend_from_slice(line.as_bytes());
304 }
305
306 let encoded = encode(&data);
307 let decoded = decode(&encoded).unwrap();
308 assert_eq!(decoded, data);
309
310 // LZ4 should achieve at least 2x compression on structured logs.
311 let ratio = data.len() as f64 / encoded.len() as f64;
312 assert!(
313 ratio > 2.0,
314 "expected >2x compression for structured logs, got {ratio:.1}x"
315 );
316 }
317
318 #[test]
319 fn random_access_block() {

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