Class ZstdDictionary

java.lang.Object
io.github.mahmoudimus.zstd.ZstdDictionary

public final class ZstdDictionary extends Object
A dictionary for frames compressed with one (RFC 8878 section 5): either a formatted dictionary, as made by zstd --train, with its own ID, entropy tables and starting offsets, or raw content with ID 0.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the size of the content frames can copy from.
    long
    id()
    Returns the dictionary ID frames refer to it by.
    of(byte[] data)
    Parses data: a formatted dictionary if it starts with the dictionary magic, else raw content.
    raw(byte[] content)
    Treats all of content as a raw-content dictionary (ID 0).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • of

      public static ZstdDictionary of(byte[] data) throws ZstdException
      Parses data: a formatted dictionary if it starts with the dictionary magic, else raw content.
      Parameters:
      data - encoded dictionary or raw dictionary content
      Returns:
      a dictionary containing a copy of the content
      Throws:
      ZstdException - if a formatted dictionary is malformed
    • raw

      public static ZstdDictionary raw(byte[] content)
      Treats all of content as a raw-content dictionary (ID 0).
      Parameters:
      content - bytes available as history before a frame's first output byte
      Returns:
      a dictionary containing a copy of the supplied content
    • id

      public long id()
      Returns the dictionary ID frames refer to it by.
      Returns:
      the unsigned 32-bit dictionary ID, or 0 for raw content
    • contentSize

      public int contentSize()
      Returns the size of the content frames can copy from.
      Returns:
      the dictionary content size in bytes