Dictionary Compression
Dictionary compression reduces repeated Base64 and image transfer overhead by storing reusable data chunks and referencing them by hash.
Methods
Section titled “Methods”| Method |
|---|
clearDictionary() : () |
compressWithDict(base64Data : string) : table |
decompressFromDict(hashMap : table) : string |
getChunk(hash : string) : string |
getDictionaryStats() : string |
hasChunk(hash : string) : boolean |
clearDictionary
Section titled “clearDictionary”Clears all stored dictionary chunks.
Use this when you want to reset the current compression state.
Example
Section titled “Example”gpu.clearDictionary()compressWithDict
Section titled “compressWithDict”Compresses Base64 data using the current dictionary.
Repeated chunks may be replaced with references to already stored data.
Requires: base64Data : string
Returns: Compression result table.
Example
Section titled “Example”local packed = gpu.compressWithDict(base64Data)decompressFromDict
Section titled “decompressFromDict”Reconstructs compressed data using dictionary chunks.
Requires: hashMap : table
Returns: Original uncompressed string.
Example
Section titled “Example”local data = gpu.decompressFromDict(hashMap)getChunk
Section titled “getChunk”Retrieves a stored dictionary chunk by its hash.
Requires: hash : string
Returns: Stored chunk data.
Example
Section titled “Example”local chunk = gpu.getChunk(hash)getDictionaryStats
Section titled “getDictionaryStats”Returns statistics about current dictionary usage.
Returns: string
Example
Section titled “Example”print(gpu.getDictionaryStats())hasChunk
Section titled “hasChunk”Checks whether a chunk exists in the dictionary.
Requires: hash : string
Returns: boolean
Example
Section titled “Example”if gpu.hasChunk(hash) then print("chunk exists")end