-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hi.
Reading and writing data packets is really expensive in any language. If you really need some connection inspection (I suppose you do) you should decode at least information packets, except data packet.
The problem is that data packet doesn't always has block size: only if it's singed. You can try to read compressed data block without decoding it with ch-go. By default clickhouse-client uses lz4 compression with singing by cityhash. Client sets compression method byte right before the query body. For quick & dirty you can assume it's on.
Layout of compressed by LZ4 data package is quite simple:
- 128-bit cityhash
- compression byte
- 32-bit size of decompressed data packet with header
- compressed data packet
So in case of LZ4 compression you should read following amount of bytes to fetch data block without decoding it:
size with header - 1 (compression byte) - 4 (decompressed size).