7979import org .junit .jupiter .params .ParameterizedTest ;
8080import org .junit .jupiter .params .provider .ValueSource ;
8181
82- import java .io .File ;
83- import java .nio .file .Files ;
84- import java .nio .file .Paths ;
8582import java .util .ArrayList ;
8683import java .util .Arrays ;
8784import java .util .Collections ;
@@ -793,10 +790,8 @@ public void testRollbackToSnapshotSkipNonExistentSnapshot() throws Exception {
793790 assertThat (result )
794791 .containsExactlyInAnyOrder ("0|0|0|binary|varbinary|mapKey:mapVal|multiset" );
795792
796- List <java .nio .file .Path > files =
797- Files .walk (new File (table .location ().toUri ().getPath ()).toPath ())
798- .collect (Collectors .toList ());
799- assertThat (files .size ()).isEqualTo (14 );
793+ FileStatus [] files = table .fileIO ().listFiles (table .location (), true );
794+ assertThat (files ).hasSize (8 );
800795 }
801796
802797 // All tags are after the rollback snapshot
@@ -819,25 +814,16 @@ public void testRollbackToSnapshotCase0() throws Exception {
819814 assertThat (result )
820815 .containsExactlyInAnyOrder ("0|0|0|binary|varbinary|mapKey:mapVal|multiset" );
821816
822- List <java .nio .file .Path > files =
823- Files .walk (new File (table .location ().toUri ().getPath ()).toPath ())
824- .collect (Collectors .toList ());
825- assertThat (files .size ()).isEqualTo (15 );
826- // table-path
827- // table-path/snapshot
817+ FileStatus [] files = table .fileIO ().listFiles (table .location (), true );
818+ assertThat (files ).hasSize (8 );
828819 // table-path/snapshot/LATEST
829820 // table-path/snapshot/EARLIEST
830821 // table-path/snapshot/snapshot-1
831- // table-path/pt=0
832- // table-path/pt=0/bucket-0
833822 // table-path/pt=0/bucket-0/data-0.orc
834- // table-path/manifest
835823 // table-path/manifest/manifest-list-1
836824 // table-path/manifest/manifest-0
837825 // table-path/manifest/manifest-list-0
838- // table-path/schema
839826 // table-path/schema/schema-0
840- // table-path/tag
841827 }
842828
843829 // One tag is at the rollback snapshot and others are after it
@@ -871,10 +857,8 @@ public void testRollbackToSnapshotCase1() throws Exception {
871857 assertThat (result )
872858 .containsExactlyInAnyOrder ("0|0|0|binary|varbinary|mapKey:mapVal|multiset" );
873859
874- List <java .nio .file .Path > files =
875- Files .walk (new File (table .location ().toUri ().getPath ()).toPath ())
876- .collect (Collectors .toList ());
877- assertThat (files .size ()).isEqualTo (16 );
860+ FileStatus [] files = table .fileIO ().listFiles (table .location (), true );
861+ assertThat (files ).hasSize (9 );
878862 // case 0 plus 1:
879863 // table-path/tag/tag-test3
880864 }
@@ -912,17 +896,14 @@ public void testRollbackToSnapshotCase2() throws Exception {
912896 assertThat (result )
913897 .containsExactlyInAnyOrder ("0|0|0|binary|varbinary|mapKey:mapVal|multiset" );
914898
915- List <java .nio .file .Path > files =
916- Files .walk (new File (table .location ().toUri ().getPath ()).toPath ())
917- .collect (Collectors .toList ());
918- assertThat (files .size ()).isEqualTo (23 );
919- // case 0 plus 7:
899+ FileStatus [] files = table .fileIO ().listFiles (table .location (), true );
900+ assertThat (files ).hasSize (14 );
901+ // case 0 plus 6:
920902 // table-path/manifest/manifest-list-2
921903 // table-path/manifest/manifest-list-3
922904 // table-path/manifest/manifest-1
923905 // table-path/snapshot/snapshot-2
924- // table-path/pt=1
925- // table-path/pt=1/bucket-0
906+ // table-path/tag/tag-test3
926907 // table-path/pt=1/bucket-0/data-0.orc
927908 }
928909
@@ -968,10 +949,8 @@ public void testRollbackToTag(boolean expire) throws Exception {
968949 assertThat (result )
969950 .containsExactlyInAnyOrder ("0|0|0|binary|varbinary|mapKey:mapVal|multiset" );
970951
971- List <java .nio .file .Path > files =
972- Files .walk (new File (table .location ().toUri ().getPath ()).toPath ())
973- .collect (Collectors .toList ());
974- assertThat (files .size ()).isEqualTo (16 );
952+ FileStatus [] files = table .fileIO ().listFiles (table .location (), true );
953+ assertThat (files ).hasSize (9 );
975954 // rollback snapshot case 0 plus 1:
976955 // table-path/tag/tag-test1
977956 }
@@ -1432,13 +1411,18 @@ public void testAsyncExpireExecutionMode() throws Exception {
14321411 store .manifestFileFactory ().create ());
14331412
14341413 List <Path > unusedFileList =
1435- Files .walk (Paths .get (tempDir .toString ()))
1436- .filter (Files ::isRegularFile )
1437- .filter (p -> !p .getFileName ().toString ().startsWith ("snapshot" ))
1438- .filter (p -> !p .getFileName ().toString ().startsWith ("schema" ))
1439- .filter (p -> !p .getFileName ().toString ().equals (LATEST ))
1440- .filter (p -> !p .getFileName ().toString ().equals (EARLIEST ))
1441- .map (p -> new Path (TraceableFileIO .SCHEME + "://" + p .toString ()))
1414+ Arrays .stream (table .fileIO ().listFiles (table .location (), true ))
1415+ .map (FileStatus ::getPath )
1416+ .filter (p -> !p .getName ().startsWith ("snapshot" ))
1417+ .filter (p -> !p .getName ().startsWith ("schema" ))
1418+ .filter (p -> !p .getName ().equals (LATEST ))
1419+ .filter (p -> !p .getName ().equals (EARLIEST ))
1420+ .map (
1421+ p ->
1422+ new Path (
1423+ TraceableFileIO .SCHEME
1424+ + ":"
1425+ + p .toString ().replace ("file:" , "" )))
14421426 .filter (p -> !filesInUse .contains (p ))
14431427 .collect (Collectors .toList ());
14441428
0 commit comments