apoc.util.compress

Details

Syntax

apoc.util.compress(data [, config ])

Description

Zips the given STRING.

Arguments

Name

Type

Description

data

STRING

The string to be compressed.

config

MAP

{ compression = "GZIP" :: ["GZIP", "BZIP2", "DEFLATE", "BLOCK_LZ4", "FRAMED_SNAPPY", "NONE"], charset = "UTF_8" ::["UTF-8", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-32", "US-ASCII", "ISO-8859-1"] } The default is: {}.

Returns

BYTEARRAY

Config parameters

The procedure support the following config parameters:

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, NONE (that is conversion to binary without compression)

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
Results
value

{"0":31.0,"1":-117.0,"2":8.0,"3":0.0,"4":0.0,"5":0.0,"6":0.0,"7":0.0,"8":0.0,"9":-1.0,"10":99.0,"11":96.0,"12":96.0,"13":-16.0,"14":101.0,"15":96.0,"16":96.0,"17":120.0,"18":2.0,"19":-60.0,"20":37.0,"21":64.0,"22":92.0,"23":4.0,"24":-60.0,"25":-103.0,"26":64.0,"27":92.0,"28":1.0,"29":-60.0,"30":10.0,"31":64.0,"32":-20.0,"33":9.0,"34":-59.0,"35":64.0,"36":118.0,"37":-56.0,"38":9.0,"39":48.0,"40":102.0,"41":-4.0,"42":-58.0,"43":2.0,"44":-28.0,"45":27.0,"46":2.0,"47":-79.0,"48":17.0,"49":16.0,"50":27.0,"51":3.0,"52":0.0,"53":113.0,"54":-125.0,"55":-33.0,"56":46.0,"57":64.0,"58":0.0,"59":0.0,"60":0.0}

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

{"0":120.0,"1":-100.0,"2":-13.0,"3":61.0,"4":-68.0,"5":-92.0,"6":-92.0,"7":40.0,"8":-77.0,"9":66.0,"10":-63.0,"11":-45.0,"12":83.0,"13":-31.0,"14":-23.0,"15":-28.0,"16":14.0,"17":32.0,"18":-6.0,"19":48.0,"20":127.0,"21":70.0,"22":-117.0,"23":-95.0,"24":-111.0,"25":49.0,"26":0.0,"27":-111.0,"28":-127.0,"29":11.0,"30":-113.0}

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

{"0":31.0,"1":-117.0,"2":8.0,"3":0.0,"4":0.0,"5":0.0,"6":0.0,"7":0.0,"8":0.0,"9":-1.0,"10":-5.0,"11":-9.0,"12":-97.0,"13":-63.0,"14":-107.0,"15":-95.0,"16":-126.0,"17":33.0,"18":-111.0,"19":33.0,"20":-105.0,"21":-95.0,"22":-128.0,"23":33.0,"24":-121.0,"25":33.0,"26":21.0,"27":0.0,"28":9.0,"29":100.0,"30":12.0,"31":-109.0,"32":16.0,"33":0.0,"34":0.0,"35":0.0}