@@ -372,7 +372,7 @@ impl Session {
372372 match self . get_group ( & path) . await {
373373 Ok ( parent) => {
374374 let nodes_iter: Vec < NodeSnapshot > = self
375- . list_nodes ( )
375+ . list_nodes ( & path )
376376 . await ?
377377 . filter_ok ( |node| node. path . starts_with ( & parent. path ) )
378378 . try_collect ( ) ?;
@@ -796,7 +796,7 @@ impl Session {
796796 pub async fn clear ( & mut self ) -> SessionResult < ( ) > {
797797 // TODO: can this be a delete_group("/") instead?
798798 let to_delete: Vec < ( NodeType , Path ) > = self
799- . list_nodes ( )
799+ . list_nodes ( & Path :: root ( ) )
800800 . await ?
801801 . map_ok ( |node| ( node. node_type ( ) , node. path ) )
802802 . try_collect ( ) ?;
@@ -850,10 +850,17 @@ impl Session {
850850 }
851851
852852 #[ instrument( skip( self ) ) ]
853- pub async fn list_nodes (
854- & self ,
855- ) -> SessionResult < impl Iterator < Item = SessionResult < NodeSnapshot > > + ' _ > {
856- updated_nodes ( & self . asset_manager , & self . change_set , & self . snapshot_id ) . await
853+ pub async fn list_nodes < ' a > (
854+ & ' a self ,
855+ parent_group : & Path ,
856+ ) -> SessionResult < impl Iterator < Item = SessionResult < NodeSnapshot > > + use < ' a > > {
857+ updated_nodes (
858+ parent_group,
859+ & self . asset_manager ,
860+ & self . change_set ,
861+ & self . snapshot_id ,
862+ )
863+ . await
857864 }
858865
859866 #[ instrument( skip( self ) ) ]
@@ -975,7 +982,7 @@ impl Session {
975982 message : & str ,
976983 properties : Option < SnapshotProperties > ,
977984 ) -> SessionResult < SnapshotId > {
978- let nodes = self . list_nodes ( ) . await ?. collect :: < Vec < _ > > ( ) ;
985+ let nodes = self . list_nodes ( & Path :: root ( ) ) . await ?. collect :: < Vec < _ > > ( ) ;
979986 // We need to populate the `splits` before calling `commit`.
980987 // In the normal chunk setting workflow, that would've been done by `set_chunk_ref`
981988 for node in nodes. into_iter ( ) . flatten ( ) {
@@ -1259,12 +1266,13 @@ impl Session {
12591266
12601267/// Warning: The presence of a single error may mean multiple missing items
12611268async fn updated_chunk_iterator < ' a > (
1269+ parent_group : & Path ,
12621270 asset_manager : & ' a AssetManager ,
12631271 change_set : & ' a ChangeSet ,
12641272 snapshot_id : & ' a SnapshotId ,
1265- ) -> SessionResult < impl Stream < Item = SessionResult < ( Path , ChunkInfo ) > > + ' a > {
1273+ ) -> SessionResult < impl Stream < Item = SessionResult < ( Path , ChunkInfo ) > > + use < ' a > > {
12661274 let snapshot = asset_manager. fetch_snapshot ( snapshot_id) . await ?;
1267- let nodes = futures:: stream:: iter ( snapshot. iter_arc ( ) ) ;
1275+ let nodes = futures:: stream:: iter ( snapshot. iter_arc ( parent_group ) ) ;
12681276 let res = nodes. and_then ( move |node| async move {
12691277 // Note: Confusingly, these NodeSnapshot instances have the metadata stored in the snapshot.
12701278 // We have not applied any changeset updates. At the moment, the downstream code only
@@ -1477,14 +1485,15 @@ pub async fn get_chunk(
14771485
14781486/// Yields nodes in the base snapshot, applying any relevant updates in the changeset
14791487async fn updated_existing_nodes < ' a > (
1488+ parent_group : & Path ,
14801489 asset_manager : & AssetManager ,
14811490 change_set : & ' a ChangeSet ,
14821491 parent_id : & SnapshotId ,
1483- ) -> SessionResult < impl Iterator < Item = SessionResult < NodeSnapshot > > + ' a + use < ' a > > {
1492+ ) -> SessionResult < impl Iterator < Item = SessionResult < NodeSnapshot > > + use < ' a > > {
14841493 let updated_nodes = asset_manager
14851494 . fetch_snapshot ( parent_id)
14861495 . await ?
1487- . iter_arc ( )
1496+ . iter_arc ( parent_group )
14881497 . filter_map_ok ( move |node| change_set. update_existing_node ( node) )
14891498 . map ( |n| match n {
14901499 Ok ( n) => Ok ( n) ,
@@ -1497,11 +1506,12 @@ async fn updated_existing_nodes<'a>(
14971506/// Yields nodes with the snapshot, applying any relevant updates in the changeset,
14981507/// *and* new nodes in the changeset
14991508async fn updated_nodes < ' a > (
1509+ parent_group : & Path ,
15001510 asset_manager : & AssetManager ,
15011511 change_set : & ' a ChangeSet ,
15021512 parent_id : & SnapshotId ,
1503- ) -> SessionResult < impl Iterator < Item = SessionResult < NodeSnapshot > > + ' a + use < ' a > > {
1504- Ok ( updated_existing_nodes ( asset_manager, change_set, parent_id)
1513+ ) -> SessionResult < impl Iterator < Item = SessionResult < NodeSnapshot > > + use < ' a > > {
1514+ Ok ( updated_existing_nodes ( parent_group , asset_manager, change_set, parent_id)
15051515 . await ?
15061516 . chain ( change_set. new_nodes_iterator ( ) . map ( Ok ) ) )
15071517}
@@ -1586,7 +1596,8 @@ async fn all_chunks<'a>(
15861596 snapshot_id : & ' a SnapshotId ,
15871597) -> SessionResult < impl Stream < Item = SessionResult < ( Path , ChunkInfo ) > > + ' a > {
15881598 let existing_array_chunks =
1589- updated_chunk_iterator ( asset_manager, change_set, snapshot_id) . await ?;
1599+ updated_chunk_iterator ( & Path :: root ( ) , asset_manager, change_set, snapshot_id)
1600+ . await ?;
15901601 let new_array_chunks =
15911602 futures:: stream:: iter ( change_set. new_arrays_chunk_iterator ( ) . map ( Ok ) ) ;
15921603 Ok ( existing_array_chunks. chain ( new_array_chunks) )
@@ -2014,6 +2025,7 @@ async fn flush(
20142025 // gather and sort nodes:
20152026 // this is a requirement for Snapshot::from_iter
20162027 let mut all_nodes: Vec < _ > = updated_nodes (
2028+ & Path :: root ( ) ,
20172029 flush_data. asset_manager . as_ref ( ) ,
20182030 flush_data. change_set ,
20192031 flush_data. parent_id ,
@@ -3213,15 +3225,15 @@ mod tests {
32133225 ds. add_group ( Path :: root ( ) , Bytes :: copy_from_slice ( b"" ) ) . await ?;
32143226 ds. add_group ( "/1" . try_into ( ) . unwrap ( ) , Bytes :: copy_from_slice ( b"" ) ) . await ?;
32153227 ds. delete_group ( "/1" . try_into ( ) . unwrap ( ) ) . await ?;
3216- assert_eq ! ( ds. list_nodes( ) . await ?. count( ) , 1 ) ;
3228+ assert_eq ! ( ds. list_nodes( & Path :: root ( ) ) . await ?. count( ) , 1 ) ;
32173229 ds. commit ( "commit" , None ) . await ?;
32183230
32193231 let ds = repository
32203232 . readonly_session ( & VersionInfo :: BranchTipRef ( "main" . to_string ( ) ) )
32213233 . await ?;
32223234 assert ! ( ds. get_group( & Path :: root( ) ) . await . is_ok( ) ) ;
32233235 assert ! ( ds. get_group( & "/1" . try_into( ) . unwrap( ) ) . await . is_err( ) ) ;
3224- assert_eq ! ( ds. list_nodes( ) . await ?. count( ) , 1 ) ;
3236+ assert_eq ! ( ds. list_nodes( & Path :: root ( ) ) . await ?. count( ) , 1 ) ;
32253237 Ok ( ( ) )
32263238 }
32273239
@@ -3237,7 +3249,7 @@ mod tests {
32373249 ds. delete_group ( "/1" . try_into ( ) . unwrap ( ) ) . await ?;
32383250 assert ! ( ds. get_group( & Path :: root( ) ) . await . is_ok( ) ) ;
32393251 assert ! ( ds. get_group( & "/1" . try_into( ) . unwrap( ) ) . await . is_err( ) ) ;
3240- assert_eq ! ( ds. list_nodes( ) . await ?. count( ) , 1 ) ;
3252+ assert_eq ! ( ds. list_nodes( & Path :: root ( ) ) . await ?. count( ) , 1 ) ;
32413253 Ok ( ( ) )
32423254 }
32433255
@@ -3255,7 +3267,7 @@ mod tests {
32553267 let ds = repository
32563268 . readonly_session ( & VersionInfo :: BranchTipRef ( "main" . to_string ( ) ) )
32573269 . await ?;
3258- assert_eq ! ( ds. list_nodes( ) . await ?. count( ) , 0 ) ;
3270+ assert_eq ! ( ds. list_nodes( & Path :: root ( ) ) . await ?. count( ) , 0 ) ;
32593271 Ok ( ( ) )
32603272 }
32613273
0 commit comments