Question
· Oct 11

Can I implement custom stream compression algorithms in IRIS for %Stream.GlobalBinary?

For space optimization, we want to apply a domain-specific compression algorithm to binary stream data before writing to %Stream.GlobalBinary. Is it possible to override or extend stream classes to include compression/decompression?

Discussion (1)2
Log in or sign up to continue

You can customize and implement your own domain-specific compression/decompression algorithms for %Stream.GlobalBinary in InterSystems IRIS. The %Stream.GlobalBinary class is designed to store binary data in global nodes, and these classes inherit from %Stream.Object, which provides a common interface for stream objects.

By default, stream compression in %Stream.GlobalBinary is controlled by the COMPRESS class parameter, which automatically compresses new stream data unless the data is deemed unsuitable for compression, such as already compressed formats (e.g., JPEG), or data in small chunks. For finer or customized control, you would need to extend or override methods in these stream classes. For example:

  1. Create a custom class extending %Stream.GlobalBinary.
  2. Implement or override methods for writing and reading the stream, embedding your compression logic during write operations and decompression logic during read operations.
  3. Utilize IRIS utility functions like $System.Util.Compress or external compression libraries via ObjectScript to handle the actual compression tasks [1][2].

Keep in mind that stream compression is enabled by default in IRIS since 2021.2 and uses efficient algorithms like ZLIB or ZSTD for compression, meaning the default implementation already provides substantial storage savings. However, implementing a custom algorithm allows optimization for specific data types or domain requirements [2][1].

Sources: