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

Function local_encode_and_download

nodedb/src/storage/cold.rs:410–436  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

408
409 #[tokio::test]
410 async fn local_encode_and_download() {
411 let dir = tempfile::tempdir().unwrap();
412 let config = ColdStorageConfig {
413 local_dir: Some(dir.path().to_path_buf()),
414 ..Default::default()
415 };
416 let cold = ColdStorage::new(config).unwrap();
417
418 let rows = vec![
419 ("d1".into(), serde_json::json!({"name": "alice", "age": 30})),
420 ("d2".into(), serde_json::json!({"name": "bob", "age": 25})),
421 ];
422 let path = cold
423 .encode_and_upload("users", 1, &rows, 100, 200)
424 .await
425 .unwrap();
426
427 assert!(path.contains("users"));
428 assert!(path.ends_with(".parquet"));
429 assert_eq!(cold.files_uploaded(), 1);
430
431 // Download and verify.
432 let bytes = cold.download_parquet(&path).await.unwrap();
433 let batches = read_parquet_with_predicate(&bytes, &[]).unwrap();
434 assert!(!batches.is_empty());
435 assert_eq!(batches[0].num_rows(), 2);
436 }
437
438 #[tokio::test]
439 async fn projected_read() {

Callers

nothing calls this directly

Calls 4

encode_and_uploadMethod · 0.80
download_parquetMethod · 0.80
pathMethod · 0.45

Tested by

no test coverage detected