MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / insert_retrieve_body

Function insert_retrieve_body

crates/table/src/table.rs:2544–2570  ·  view source on GitHub ↗
(ty: impl Into<ProductType>, val: impl Into<ProductValue>)

Source from the content-addressed store, hash-verified

2542 }
2543
2544 fn insert_retrieve_body(ty: impl Into<ProductType>, val: impl Into<ProductValue>) -> TestCaseResult {
2545 let val = val.into();
2546 let pool = PagePool::new_for_test();
2547 let mut blob_store = HashMapBlobStore::default();
2548 let mut table = table(ty.into());
2549 let (hash, row) = table.insert(&pool, &mut blob_store, &val).unwrap();
2550 let hash = hash.unwrap();
2551 prop_assert_eq!(row.row_hash(), hash);
2552 let ptr = row.pointer();
2553 prop_assert_eq!(table.pointers_for(hash), &[ptr]);
2554
2555 prop_assert_eq!(table.inner.pages.len(), 1);
2556 prop_assert_eq!(table.inner.pages[PageIndex(0)].num_rows(), 1);
2557
2558 let row_ref = table.get_row_ref(&blob_store, ptr).unwrap();
2559 prop_assert_eq!(row_ref.to_product_value(), val.clone());
2560 let bsatn_val = to_vec(&val).unwrap();
2561 prop_assert_eq!(&bsatn_val, &to_vec(&row_ref).unwrap());
2562 prop_assert_eq!(&bsatn_val, &row_ref.to_bsatn_vec().unwrap());
2563
2564 prop_assert_eq!(
2565 &table.scan_rows(&blob_store).map(|r| r.pointer()).collect::<Vec<_>>(),
2566 &[ptr]
2567 );
2568
2569 Ok(())
2570 }
2571
2572 #[test]
2573 fn repro_serialize_bsatn_empty_array() {

Calls 7

to_vecFunction · 0.85
pointerMethod · 0.80
get_row_refMethod · 0.80
tableFunction · 0.70
insertMethod · 0.65
OkFunction · 0.50
unwrapMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…