Files
zeekay ef352c1051 debrand: rename the wire client name, prose and linter config
proto.Name is sent in ClientHello and lands in the server's system.query_log,
so it is wire visible; it now reads datastore/native and is covered by a test.
Verified against the live server: the handshake succeeds and the new name
appears in query_log.

goimports' local-prefixes still named the upstream module, so it was not
grouping this module's own imports.

Doc comments, the deprecated-error markers in proto/error_codes.go and the
package prose are swept. Dead references are removed rather than repointed:
go-faster.org/docs/clickhouse and the mangled Datastore/clickhouse-cpp link
both 404, and the list of other vendors' clients does not belong here.

Four things deliberately keep the vendor name, and CI records why:
LICENSE and AUTHORS are the copyright notices Apache-2.0 requires; db.system in
query.go is an OpenTelemetry enum whose registered value for this DBMS is fixed
by the specification, so emitting anything else would be non-conformant; and
README names clickhouse-local, which is genuinely the binary our own server
image ships.

Numeric error codes and protocol revision constants are untouched.
2026-07-26 11:50:36 -07:00

73 lines
1.5 KiB
Go

// Package compress implements compression support.
package compress
import (
"fmt"
"github.com/go-faster/city"
)
//go:generate go run github.com/dmarkham/enumer -transform upper -type Method -output method_enum.go
// Method is compression codec.
type Method byte
// Possible compression methods.
const (
None Method = iota
LZ4
LZ4HC
ZSTD
NumMethods int = iota
)
type methodEncoding byte
const (
encodedNone methodEncoding = 0x02
encodedLZ4 methodEncoding = 0x82
encodedLZ4HC methodEncoding = encodedLZ4
encodedZSTD methodEncoding = 0x90
)
var methodTable = map[Method]methodEncoding{
None: encodedNone,
LZ4: encodedLZ4,
LZ4HC: encodedLZ4HC,
ZSTD: encodedZSTD,
}
// Level for supporting compression codecs.
type Level uint32
// Constants for compression encoding.
//
// See the server's native block compression format for reference.
const (
checksumSize = 16
compressHeaderSize = 1 + 4 + 4
headerSize = checksumSize + compressHeaderSize
// Limiting total data/block size to protect from possible OOM.
maxDataSize = 1024 * 1024 * 128 // 128MB
maxBlockSize = maxDataSize
hRawSize = 17
hDataSize = 21
hMethod = 16
)
// CorruptedDataErr means that provided hash mismatch with calculated.
type CorruptedDataErr struct {
Actual city.U128
Reference city.U128
RawSize int
DataSize int
}
func (c *CorruptedDataErr) Error() string {
return fmt.Sprintf("corrupted data: %s (actual), %s (reference), compressed size: %d, data size: %d",
FormatU128(c.Actual), FormatU128(c.Reference), c.RawSize, c.DataSize,
)
}