apoc.util.compress

Function APOC Core

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

Signature

apoc.util.compress(data :: STRING?, config = {} :: MAP?) :: (LIST? OF ANY?)

Input parameters

Name Type Default

data

STRING?

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 compress the string
Accepted values are: GZIP, BZIP2, DEFLATE, BLOCK_LZ4, FRAMED_SNAPPY

charset

enum

UTF-8

The charset used to compress the string
Accepted values are: UTF-8, UTF-16, UTF-16BE, UTF-16LE, UTF-32, US-ASCII, ISO-8859-1

Usage Examples

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

[31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 99, 96, 96, 240, 101, 96, 96, 120, 2, 196, 37, 64, 92, 4, 196, 153, 64, 92, 1, 196, 10, 64, 236, 9, 197, 64, 118, 200, 9, 48, 102, 252, 198, 2, 228, 27, 2, 177, 17, 16, 27, 3, 0, 113, 131, 223, 46, 64, 0, 0, 0]

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

[120, 156, 243, 61, 188, 164, 164, 40, 179, 66, 193, 211, 83, 225, 233, 228, 14, 32, 250, 48, 127, 70, 139, 161, 145, 49, 0, 145, 129, 11, 143]

Return apoc.util.compress("Example", {charset: 'UTF-16'}) AS value
Table 4. Results
value

[31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 251, 247, 159, 193, 149, 161, 130, 33, 145, 33, 151, 161, 128, 33, 135, 33, 21, 0, 9, 100, 12, 147, 16, 0, 0, 0]