protected Collection < FileSystemDatasetVersion > listQualifiedRawFileSystemDatasetVersions ( Collection < FileSystemDatasetVersion > allVersions ) { return Lists . newArrayList ( Collections2 . filter ( allVersions , new Predicate < FileSystemDatasetVersion > ( ) { @ Override public boolean apply ( FileSystemDatasetVersion version ) { Iterable < Path > refinedDatasetPaths = getRefinedDatasetPaths ( version ) ; try { Optional < Long > latestRawDatasetModTime = getLatestModTime ( version . getPaths ( ) ) ; Optional < Long > latestRefinedDatasetModTime = getLatestModTime ( refinedDatasetPaths ) ; return latestRawDatasetModTime . isPresent ( ) && latestRefinedDatasetModTime . isPresent ( ) && latestRawDatasetModTime . get ( ) <= latestRefinedDatasetModTime . get ( ) ; } catch ( IOException e ) { throw new RuntimeException ( "Failed to get modification time" , e ) ; } } } ) ) ; }
A raw dataset version is qualified to be deleted iff the corresponding refined paths exist and the latest mod time of all files is in the raw dataset is earlier than the latest mod time of all files in the refined paths .