public static boolean delete ( Descriptor desc , Set < Component > components ) { // remove the DATA component first if it exists if ( components . contains ( Component . DATA ) ) FileUtils . deleteWithConfirm ( desc . filenameFor ( Component . DATA ) ) ; for ( Component component : components ) { if ( component . equals ( Component . DATA ) || component . equals ( Component . SUMMARY ) ) continue ; FileUtils . deleteWithConfirm ( desc . filenameFor ( component ) ) ; } FileUtils . delete ( desc . filenameFor ( Component . SUMMARY ) ) ; logger . debug ( "Deleted {}" , desc ) ; return true ; }
We use a ReferenceQueue to manage deleting files that have been compacted and for which no more SSTable references exist . But this is not guaranteed to run for each such file because of the semantics of the JVM gc . So we write a marker to compactedFilename when a file is compacted ; if such a marker exists on startup the file should be removed .