Class ZstandardLoadOptions


  • public class ZstandardLoadOptions
    extends Object

    Options with which ZstandardArchive is loaded from a compressed file. Contains event raised on extraction.

    • Constructor Detail

      • ZstandardLoadOptions

        public ZstandardLoadOptions()
    • Method Detail

      • getExtractionProgressed

        public Event<ProgressEventArgs> getExtractionProgressed()

        Gets an event that is raised when some bytes have been extracted.

        
             long length = 10_000_000;
             ZStandardLoadOptions loadOptions = new ZStandardLoadOptions();
             loadOptions.setExtractionProgressed((sender, args) -> {
                 int percent = (int)((100 * args.getProceededBytes()) / length);
             });
             ZstandardArchive archive = new ZstandardArchive("archive.zst", loadOptions);
         

        Event sender is the ZstandardArchive instance which extraction is progressed.

        Returns:
        an event that is raised when some bytes have been extracted
      • setExtractionProgressed

        public void setExtractionProgressed​(Event<ProgressEventArgs> value)

        Sets an event that is raised when some bytes have been extracted.

        
             long length = 10_000_000;
             ZStandardLoadOptions loadOptions = new ZStandardLoadOptions();
             loadOptions.setExtractionProgressed((sender, args) -> {
                 int percent = (int)((100 * args.getProceededBytes()) / length);
             });
             ZstandardArchive archive = new ZstandardArchive("archive.zst", loadOptions);
         

        Event sender is the ZstandardArchive instance which extraction is progressed.

        Parameters:
        value - an event that is raised when some bytes have been extracted
      • setCancellationFlag

        public void setCancellationFlag​(CancellationFlag value)

        Sets a cancellation flag used to cancel the extraction operation.

        Cancel Zstandard archive extraction after a certain time.

        
             try (CancellationFlag cf = new CancellationFlag()) {
                 cf.cancelAfter(TimeUnit.SECONDS.toMillis(60));
                 ZstandardLoadOptions options = new ZstandardLoadOptions();
                 options.setCancellationFlag(cf);
                 try (ZstandardArchive a = new ZstandardArchive("big.zstd", options)) {
                     try {
                         a.extract("data.bin");
                     } catch (OperationCanceledException e) {
                         System.out.println("Extraction was cancelled after 60 seconds");
                     }
                 }
             }
         
        Cancellation mostly results in some data not being extracted.

        Parameters:
        value - a cancellation flag used to cancel the extraction operation.