ClickHouse/tests/queries/0_stateless/01621_clickhouse_compressor.sh

34 lines
993 B
Bash
Raw Normal View History

2020-12-29 20:10:51 +00:00
#!/usr/bin/env bash
2020-12-30 17:55:10 +00:00
# shellcheck source=../shell_config.sh
2020-12-29 20:10:51 +00:00
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
2020-12-30 15:53:33 +00:00
# shellcheck source=../shell_config.sh
2020-12-29 20:10:51 +00:00
. "$CURDIR"/../shell_config.sh
set -e
TEMP_DIR="$(mktemp -d /tmp/clickhouse.test..XXXXXX)"
cd "${TEMP_DIR:?}"
function cleanup()
{
rm -fr "${TEMP_DIR:?}"
}
trap cleanup EXIT
# This is random garbage, so compression ratio will be very low.
tr -cd 'a-z0-9' < /dev/urandom | head -c1M > input
# stdin/stdout streams
$CLICKHOUSE_COMPRESSOR < input > output
diff -q <($CLICKHOUSE_COMPRESSOR --decompress < output) input
# positional arguments, and that fact that input/output will be overwritten
$CLICKHOUSE_COMPRESSOR input output
diff -q <($CLICKHOUSE_COMPRESSOR --decompress output) input
# --offset-in-decompressed-block
diff -q <($CLICKHOUSE_COMPRESSOR --decompress --offset-in-decompressed-block 10 output) <(tail -c+$((10+1)) input)
# TODO: --offset-in-compressed-file using some .bin file (via clickhouse-local + check-marks)