Support KANZI and BZIP2 in `RunScript` by manticore-projects · Pull Request #4256 · h2database/h2database

This is the continuation of PR #4254

  • move KANZI and BZIP2 into the CompressionTool
  • even better compression for KANZI
  • support KANZI and BZIP2 in RunScript and friends
  • workaround some odd 0bytes EOF behavior of the KANZI CompressedInputStream
  • update the documentation

Recover/Archive

# Database: testdb.mv.db (1.7GB)

# parallel compression using KANZI from https://github.com/flanglet/kanzi
java -Xmx8g -cp "h2-2.3.239-SNAPSHOT.jar:kanzi-2.4.0.jar" org.h2.tools.DirectRecover -dir ~/ -db testdb -compress kanzi

# serial compression using BZip2 from https://dlcdn.apache.org/commons/compress/binaries/
java -Xmx8g -cp "h2-2.3.239-SNAPSHOT.jar:commons-compress-1.28.0.jar" org.h2.tools.DirectRecover -dir ~/ -db testdb -compress bzip2

# serial compression using GZIP w/o any additional libraries
java -Xmx8g -cp "h2-2.3.239-SNAPSHOT.jar" org.h2.tools.DirectRecover -dir ~/ -db testdb -compress gzip

# resulting SQL script files on a AMD Zen3 Ryzen5:
# KANZI: testdb.h2.sql.knz (114.1 MB in 128 secs)
# BZip2: testdb.h2.sql.bz2 (153.7 MB in 18 mins)
# GZip:  testdb.h2.sql.gz  (207.4 MB in 74 secs)

Restore

#KANZI from https://github.com/flanglet/kanzi
java -Xmx8G -cp "h2-2.3.239-SNAPSHOT.jar:kanzi-2.4.0.jar" org.h2.tools.RunScript -url jdbc:h2:~/testdb -user sa -script ~/testdb.h2.sql.knz -options "COMPRESSION kanzi"

#BZIP2 from https://dlcdn.apache.org/commons/compress/binaries/
java -Xmx8G -cp "h2-2.3.239-SNAPSHOT.jar:commons-compress-1.28.0.jar" org.h2.tools.RunScript -url jdbc:h2:~/testdb -user sa -script ~/testdb.h2.sql.bz2 -options "COMPRESSION bzip2"