Skip to content

Dictionary Compression

Dictionary compression reduces repeated Base64 and image transfer overhead by storing reusable data chunks and referencing them by hash.

Method
clearDictionary() : ()
compressWithDict(base64Data : string) : table
decompressFromDict(hashMap : table) : string
getChunk(hash : string) : string
getDictionaryStats() : string
hasChunk(hash : string) : boolean

Clears all stored dictionary chunks.

Use this when you want to reset the current compression state.

gpu.clearDictionary()

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.

local packed = gpu.compressWithDict(base64Data)

Reconstructs compressed data using dictionary chunks.

Requires: hashMap : table

Returns: Original uncompressed string.

local data = gpu.decompressFromDict(hashMap)

Retrieves a stored dictionary chunk by its hash.

Requires: hash : string

Returns: Stored chunk data.

local chunk = gpu.getChunk(hash)

Returns statistics about current dictionary usage.

Returns: string

print(gpu.getDictionaryStats())

Checks whether a chunk exists in the dictionary.

Requires: hash : string

Returns: boolean

if gpu.hasChunk(hash) then
print("chunk exists")
end