Parallel composition of ZIP Archives

Overview

Aspose.ZIP API provides an ability to compose ZIP archives. Because the entries of such archive can be compressed independently, it is possible to parallelize archive creation to some degree.

ZIP multithreaded: explanation

Use ParallelOptions to indicate that archive needs to be prepared with several CPU cores.

Setting ParallelCompressInMemory ( getParallelCompressInMemory/ setParallelCompressInMemory) indicates the strategy we choose to multitask. Here are three options:

We encourage you to play with different modes of parallel compression on your typical data to determine what is the best settings in your case.

Sample

 1try (FileOutputStream zipFile = new FileOutputStream("archive.zip")) {
 2    try (Archive archive = new Archive()) {
 3        archive.createEntry("first.bin", "data1.bin");
 4        ...
 5        archive.createEntry("last.bin", "dataN.bin");
 6        ParallelOptions parallelOptions = new ParallelOptions();
 7        parallelOptions.setParallelCompressInMemory(ParallelCompressionMode.Always);
 8        ArchiveSaveOptions options = new ArchiveSaveOptions();
 9        options.setParallelOptions(parallelOptions);
10        archive.save(zipFile, options);
11    }
12} catch (IOException ex) {
13    System.out.println(ex);
14}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.