static void cleanupIndexSegmentFilesForLogSegment(String dataDir, final LogSegmentName logSegmentName)
      throws StoreException {
    File[] filesToCleanup = new File(dataDir).listFiles(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        if (logSegmentName.toString().isEmpty()) {
          return (name.endsWith(IndexSegment.INDEX_SEGMENT_FILE_NAME_SUFFIX) || name.endsWith(
              IndexSegment.BLOOM_FILE_NAME_SUFFIX));
        } else {
          return name.startsWith(logSegmentName.toString() + BlobStore.SEPARATOR) && (
              name.endsWith(IndexSegment.INDEX_SEGMENT_FILE_NAME_SUFFIX) || name.endsWith(
                  IndexSegment.BLOOM_FILE_NAME_SUFFIX));
        }
      }
    });
    if (filesToCleanup == null) {
      throw new StoreException("Failed to list index segment files", StoreErrorCodes.IOError);
    }
    for (File file : filesToCleanup) {
      if (!file.delete()) {
        throw new StoreException("Could not delete file named " + file, StoreErrorCodes.UnknownError);
      }
    }
  }
Cleans up all files related to index segments that refer to the log segment with name {@code logSegmentName}.
 @param dataDir the directory where the index files are.
@param logSegmentName the name of the log segment whose index segment related files need to be deleteds.
@throws StoreException if {@code dataDir} could not be read or if a file could not be deleted.
ambry-store/src/main/java/com/github/ambry/store/PersistentIndex.java