I was recently engaged in a bug where the size of container caused problems. The solution we arrived at was to implement compression of the container. The solution is trivial; but the APIs to get there took me a while to discover, and as I couldn't find any other post on this, I'm sharing it.

How to implement compression/decompression of pack/unpack methods using BinData and ContainerClass.

 

public container pack()  
{
    // Business as usual...          
    container result = [#currentVersion, #currentList];
 
    // Compress          
    ContainerClass containerClass = new ContainerClass(result);        
    binData = new BinData();        
    binData.setData(containerClass.toBlob());        
    binData.compressLZ77(12);        
    return  binData.getData();    
}    
 
public boolean unpack(container  _compressed)  
{
    // Decompress          
    BinData binData = new BinData();        
    binData.setData(_compressed);        
    binData.decompressLZ77();        
    container packed = ContainerClass::blob2Container(binData.getData());
 
    // Business as usual...          
    Version version = RunBase::getVersion(packed);        
    switch (version)
    {            
        case #CurrentVersion:  
             [version, #currentList] = packed;                
            break;            
        default:  
            return false;        
    }        
    return true;    
}    

THIS POST IS PROVIDED AS-IS; AND CONFERS NO RIGHTS.