Class ZstdOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class ZstdOutputStream
    extends java.io.FilterOutputStream
    OutputStream filter that compresses the data using Zstd compression
    • Constructor Detail

      • ZstdOutputStream

        @Deprecated
        public ZstdOutputStream​(java.io.OutputStream outStream,
                                int level,
                                boolean closeFrameOnFlush,
                                boolean useChecksums)
                         throws java.io.IOException
        Deprecated.
        Use ZstdOutputStream() or ZstdOutputStream(level) and set the other params with the setters
        Throws:
        java.io.IOException
      • ZstdOutputStream

        @Deprecated
        public ZstdOutputStream​(java.io.OutputStream outStream,
                                int level,
                                boolean closeFrameOnFlush)
                         throws java.io.IOException
        Deprecated.
        Use ZstdOutputStream() or ZstdOutputStream(level) and set the other params with the setters
        Throws:
        java.io.IOException
      • ZstdOutputStream

        public ZstdOutputStream​(java.io.OutputStream outStream,
                                int level)
                         throws java.io.IOException
        create a new compressing OutputStream
        Parameters:
        outStream - the stream to wrap
        level - the compression level
        Throws:
        java.io.IOException
      • ZstdOutputStream

        public ZstdOutputStream​(java.io.OutputStream outStream)
                         throws java.io.IOException
        create a new compressing OutputStream
        Parameters:
        outStream - the stream to wrap
        Throws:
        java.io.IOException
      • ZstdOutputStream

        public ZstdOutputStream​(java.io.OutputStream outStream,
                                BufferPool bufferPool,
                                int level)
                         throws java.io.IOException
        create a new compressing OutputStream
        Parameters:
        outStream - the stream to wrap
        bufferPool - the pool to fetch and return buffers
        Throws:
        java.io.IOException
      • ZstdOutputStream

        public ZstdOutputStream​(java.io.OutputStream outStream,
                                BufferPool bufferPool)
                         throws java.io.IOException
        create a new compressing OutputStream
        Parameters:
        outStream - the stream to wrap
        bufferPool - the pool to fetch and return buffers
        Throws:
        java.io.IOException
    • Method Detail

      • setFinalize

        @Deprecated
        public void setFinalize​(boolean finalize)
        Deprecated.
        If you don't rely on finalizers, use `ZstdOutputStreamNoFinalizer` instead.
        Enable or disable class finalizers If finalizers are disabled the responsibility fir calling the `close` method is on the consumer.
        Parameters:
        finalize - default `true` - finalizers are enabled
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • recommendedCOutSize

        public static long recommendedCOutSize()
      • setChecksum

        public ZstdOutputStream setChecksum​(boolean useChecksums)
                                     throws java.io.IOException
        Enable checksums for the compressed stream. Default: false
        Throws:
        java.io.IOException
      • setLong

        public ZstdOutputStream setLong​(int windowLog)
                                 throws java.io.IOException
        Set the Long Distance Matching. Values for windowLog outside the range 10-27 will disable and reset LDM
        Throws:
        java.io.IOException
      • setWorkers

        public ZstdOutputStream setWorkers​(int n)
                                    throws java.io.IOException
        Enable use of worker threads for parallel compression. Default: no worker threads.
        Throws:
        java.io.IOException
      • setOverlapLog

        public ZstdOutputStream setOverlapLog​(int overlapLog)
                                       throws java.io.IOException
        Advanced Compression Option: Set the amount of data reloaded from the previous job. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.
        Throws:
        java.io.IOException
      • setJobSize

        public ZstdOutputStream setJobSize​(int jobSize)
                                    throws java.io.IOException
        Advanced Compression Option: Set the size of each compression job. Only applies when multi threaded compression is enabled. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.
        Throws:
        java.io.IOException
      • setTargetLength

        public ZstdOutputStream setTargetLength​(int targetLength)
                                         throws java.io.IOException
        Advanced Compression Option: Set the target match length. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.
        Throws:
        java.io.IOException
      • setMinMatch

        public ZstdOutputStream setMinMatch​(int minMatch)
                                     throws java.io.IOException
        Advanced Compression Option: Set the minimum match length. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.
        Throws:
        java.io.IOException
      • setSearchLog

        public ZstdOutputStream setSearchLog​(int searchLog)
                                      throws java.io.IOException
        Advanced Compression Option: Set the maximum number of searches in a hash chain or a binary tree using logarithmic scale. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.
        Throws:
        java.io.IOException
      • setChainLog

        public ZstdOutputStream setChainLog​(int chainLog)
                                     throws java.io.IOException
        Advanced Compression Option: Set the maximum number of bits for the secondary search structure. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.
        Throws:
        java.io.IOException
      • setHashLog

        public ZstdOutputStream setHashLog​(int hashLog)
                                    throws java.io.IOException
        Advanced Compression Option: Set the maximum number of bits for a hash table. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.
        Throws:
        java.io.IOException
      • setWindowLog

        public ZstdOutputStream setWindowLog​(int windowLog)
                                      throws java.io.IOException
        Advanced Compression Option: Set the maximum number of bits for a match distance. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.
        Throws:
        java.io.IOException
      • setStrategy

        public ZstdOutputStream setStrategy​(int strategy)
                                     throws java.io.IOException
        Advanced Compression Option: Set the strategy used by a match finder. See https://facebook.github.io/zstd/zstd_manual.html#Chapter5 for more information.
        Throws:
        java.io.IOException
      • setCloseFrameOnFlush

        public ZstdOutputStream setCloseFrameOnFlush​(boolean closeOnFlush)
        Enable closing the frame on flush. This will guarantee that it can be ready fully if the process crashes before closing the stream. On the downside it will negatively affect the compression ratio. Default: false.
      • setDict

        public ZstdOutputStream setDict​(byte[] dict)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] src,
                          int offset,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(int i)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Flushes the output
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterOutputStream
        Throws:
        java.io.IOException