private static void updateStats(DirDiff dirDiff, Stats stats) {
    stats.filesAdded += dirDiff.getFilesAdded().size();
    stats.filesRetained += dirDiff.getFilesRetained().size();
    stats.filesRemoved += dirDiff.getFilesRemoved().size();

    stats.bytesAdded += dirDiff.getFilesAdded().stream().mapToLong(File::length).sum();
    stats.bytesRetained += dirDiff.getFilesRetained().stream().mapToLong(f -> f.getFileMetadata().getSize()).sum();
    stats.bytesRemoved += dirDiff.getFilesRemoved().stream().mapToLong(f -> f.getFileMetadata().getSize()).sum();

    for (DirDiff subDirAdded: dirDiff.getSubDirsAdded()) {
      stats.subDirsAdded += 1;
      updateStats(subDirAdded, stats);
    }
    for (DirDiff subDirRetained: dirDiff.getSubDirsRetained()) {
      stats.subDirsRetained += 1;
      updateStats(subDirRetained, stats);
    }
    for (DirIndex subDirRemoved: dirDiff.getSubDirsRemoved()) {
      stats.subDirsRemoved += 1;
      updateStatsForDirRemoved(subDirRemoved, stats);
    }
  }
Subdirectories that are already present in the previous snapshot, but don't exist in the local snapshot,
and hence all of their contents need to be recursively removed.
samza-core/src/main/java/org/apache/samza/storage/blobstore/diff/DirDiff.java