Kafka Connect GzipDecompress SMT Usage Reference for Confluent Platform
The GzipDecompress SMT (io.confluent.connect.transforms.GzipDecompress) decompresses a Gzip-compressed byte array back to its original uncompressed byte array.
Note
GzipDecompress is not available for managed connectors.
Description
The GzipDecompress SMT decompresses a byte-array input that was previously Gzip-compressed. It works only with byte-array (BYTES) input.
The SMT decompresses the input using java.util.zip.GZIPInputStream and returns the resulting byte array.
Based on your requirements, use the transformation type designed for the record key (io.confluent.connect.transforms.GzipDecompress$Key) or the record value (io.confluent.connect.transforms.GzipDecompress$Value).
Installation
Confluent develops this transformation and does not ship it by default with Apache Kafka® or Confluent Platform. You can install this transformation using the confluent connect plugin install command:
confluent connect plugin install confluentinc/connect-transforms:latest
Examples
The following example shows how to configure and use GzipDecompress.
Gzip-decompress a byte-array value
This configuration snippet shows how to decompress a Gzip-compressed value.
"transforms": "gzipDecompress",
"transforms.gzipDecompress.type": "io.confluent.connect.transforms.GzipDecompress$Value"
Because the values are binary, this example uses base64 to display them as readable text. To prepare the input, encode the text Hello world as base64, then Gzip-compress the result:
# Encode "Hello world" as base64
echo "Hello world" | base64
# Output: SGVsbG8gd29ybGQK
# Gzip-compress the base64-encoded value
echo "SGVsbG8gd29ybGQK" | gzip
The SMT decompresses the Gzip-compressed value back to the base64-encoded text:
Before: the Gzip-compressed bytes produced by compressing
SGVsbG8gd29ybGQKAfter:
SGVsbG8gd29ybGQK(the base64 encoding ofHello world)
Predicates
Configure transformations with predicates to ensure they only process records satisfying a particular condition. You can also use predicates in a transformation chain along with the Kafka Connect Filter (Kafka) SMT Usage Reference for Confluent Platform to conditionally filter specific records. For more information, refer to Predicates.