Class ParallelFzipWriter

java.lang.Object
com.e1c.g5.v8.internal.fastzip.ParallelFzipWriter
All Implemented Interfaces:
IFzipWriter, Closeable, AutoCloseable

public class ParallelFzipWriter extends Object implements IFzipWriter
Implementation of IFzipWriter, which supports parallel compression.
  • Constructor Details

    • ParallelFzipWriter

      public ParallelFzipWriter(Path archPath, IFzipEntryRegistry registry, int chunkSize, int numWorkers, boolean memoryMapped, int level) throws IOException
      Constructs a new parallel FastZIP writer.
      Parameters:
      archPath - the path to the FastZIP archive, if the file already exists it will be overwritten, cannot be null
      registry - the FastZIP entry registry, cannot be null
      chunkSize - chunk size in bytes, see com.e1c.g5.v8.fastzip
      numWorkers - number of threads to be used for compression, must be positive
      memoryMapped - whether memory mapped IO shall be used
      level - Zstandard compression level
      Throws:
      IOException - if the file could not be opened
  • Method Details

    • setProgressListener

      public void setProgressListener(IProgressListener progressListener)
      Description copied from interface: IFzipWriter
      Sets a progress listener. The listener is used to track progress of IFzipWriter.write(IFzipEntry[]) operation.
      Specified by:
      setProgressListener in interface IFzipWriter
      Parameters:
      progressListener - the progress listener, or null to remove a previously set listener
    • write

      public void write(IFzipEntry[] entries) throws IOException
      Description copied from interface: IFzipWriter
      Writes entries to the archive. The entries must belong to the registry of this writer. Reports the progress to a progress listener if it was set.

      If the operation fails the writer might end up in a closed state and no guarantees on the contents and consistency of the archive are provided.

      Specified by:
      write in interface IFzipWriter
      Parameters:
      entries - the entries, cannot be null, cannot contain null values
      Throws:
      FzipException - if the writer failed to compress the entries for any reason
      IOException - if an IO error occurs
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException