apoc.util.decompress

Function APOC Core

apoc.util.decompress(compressed, {config}) | return a string from a compressed byte[] in various format

Signature

apoc.util.decompress(data :: BYTEARRAY?, config = {} :: MAP?) :: (STRING?)

Input parameters

Name Type Default

data

BYTEARRAY?

null

config

MAP?

{}

Config parameters

The procedure support the following config parameters:

Table 1. Config parameters
name type default description

compression

enum

GZIP

The compression algorithm used to decompress the byte[]
Accepted values are: GZIP, BZIP2, DEFLATE, BLOCK_LZ4, FRAMED_SNAPPY, NONE (that is conversion to string without compression)

charset

enum

UTF-8

The charset used to decompress the byte[]
Accepted values are: UTF-8, UTF-16, UTF-16BE, UTF-16LE, UTF-32, US-ASCII, ISO-8859-1

Usage Examples

WITH apoc.util.compress("Mätrix II 哈哈😄123", {charset: 'UTF-32'}) as compressed
RETURN apoc.util.decompress(compressed, {charset: 'UTF-32'}) AS value
Table 2. Results
value

"Mätrix II 哈哈😄123"

WITH apoc.util.compress("Mätrix II 哈哈😄123", {compression: 'DEFLATE'}) as compressed
RETURN apoc.util.decompress(compressed, {compression: 'DEFLATE'}) AS value
Table 3. Results
value

"Mätrix II 哈哈😄123"

WITH apoc.util.compress("Example", {charset: 'UTF-16'}) as compressed
RETURN apoc.util.decompress(compressed, {charset: 'UTF-16'}) AS value
Table 4. Results
value

"Example"