Interface Dictionary

All Known Implementing Classes:
LRUDictionary

@Private public interface Dictionary
Dictionary interface Dictionary indexes should be either bytes or shorts, only positive. (The first bit is reserved for detecting whether something is compressed or not).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
     
  • Method Summary

    Modifier and Type
    Method
    Description
    short
    addEntry(byte[] data, int offset, int length)
    Adds an entry to the dictionary.
    void
    Flushes the dictionary, empties all values.
    short
    findEntry(byte[] data, int offset, int length)
    Finds the index of an entry.
    short
    findEntry(ByteBuffer data, int offset, int length)
    Finds the index of an entry.
    byte[]
    getEntry(short idx)
    Gets an entry from the dictionary.
    void
    init(int initialSize)
     
    static void
    write(OutputStream out, byte[] data, int offset, int length, Dictionary dict)
    Helper methods to write the dictionary data to the OutputStream
    static void
    write(OutputStream out, ByteBuffer data, int offset, int length, Dictionary dict)
    Helper methods to write the dictionary data to the OutputStream
  • Field Details

  • Method Details

    • init

      void init(int initialSize)
    • getEntry

      byte[] getEntry(short idx)
      Gets an entry from the dictionary.
      Parameters:
      idx - index of the entry
      Returns:
      the entry, or null if non existent
    • findEntry

      short findEntry(byte[] data, int offset, int length)
      Finds the index of an entry. If no entry found, we add it.
      Parameters:
      data - the byte array that we're looking up
      offset - Offset into data to add to Dictionary.
      length - Length beyond offset that comprises entry; must be > 0.
      Returns:
      the index of the entry, or NOT_IN_DICTIONARY if not found
    • findEntry

      short findEntry(ByteBuffer data, int offset, int length)
      Finds the index of an entry. If no entry found, we add it.
      Parameters:
      data - the ByteBuffer that we're looking up
      offset - Offset into data to add to Dictionary.
      length - Length beyond offset that comprises entry; must be > 0.
      Returns:
      the index of the entry, or NOT_IN_DICTIONARY if not found
    • addEntry

      short addEntry(byte[] data, int offset, int length)
      Adds an entry to the dictionary. Be careful using this method. It will add an entry to the dictionary even if it already has an entry for the same data. Call {findEntry(byte[], int, int)} to add without duplicating dictionary entries.
      Parameters:
      data - the entry to add
      offset - Offset into data to add to Dictionary.
      length - Length beyond offset that comprises entry; must be > 0.
      Returns:
      the index of the entry
    • clear

      void clear()
      Flushes the dictionary, empties all values.
    • write

      static void write(OutputStream out, byte[] data, int offset, int length, Dictionary dict) throws IOException
      Helper methods to write the dictionary data to the OutputStream
      Parameters:
      out - the outputstream to which data needs to be written
      data - the data to be written in byte[]
      offset - the offset
      length - length to be written
      dict - the dictionary whose contents are to written
      Throws:
      IOException
    • write

      static void write(OutputStream out, ByteBuffer data, int offset, int length, Dictionary dict) throws IOException
      Helper methods to write the dictionary data to the OutputStream
      Parameters:
      out - the outputstream to which data needs to be written
      data - the data to be written in ByteBuffer
      offset - the offset
      length - length to be written
      dict - the dictionary whose contents are to written
      Throws:
      IOException