private CompressionType getCorrectCompressionAlgorithm()

in priam/src/main/java/com/netflix/priam/backup/BackupHelperImpl.java [89:111]


    private CompressionType getCorrectCompressionAlgorithm(
            AbstractBackupPath path, Set<String> compressedFiles) {
        if (!AbstractBackupPath.BackupFileType.isV2(path.getType())
                || path.getLastModified().toEpochMilli()
                        < config.getCompressionTransitionEpochMillis()) {
            return CompressionType.SNAPPY;
        }
        String file = path.getFileName();
        BackupsToCompress which = config.getBackupsToCompress();
        switch (which) {
            case NONE:
                return CompressionType.NONE;
            case ALL:
                return CompressionType.SNAPPY;
            case IF_REQUIRED:
                int splitIndex = file.lastIndexOf('-');
                return splitIndex >= 0 && compressedFiles.contains(file.substring(0, splitIndex))
                        ? CompressionType.NONE
                        : CompressionType.SNAPPY;
            default:
                throw new IllegalArgumentException("NONE, ALL, UNCOMPRESSED only. Saw: " + which);
        }
    }