mirror of
https://github.com/hanzo-ds/native.git
synced 2026-10-30 20:00:34 +00:00
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.
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package proto
|
|
|
|
import (
|
|
"encoding/binary"
|
|
|
|
"github.com/go-faster/errors"
|
|
)
|
|
|
|
var _ = binary.LittleEndian // Datastore uses LittleEndian
|
|
|
|
// DecodeColumn decodes BFloat16 rows from the given reader.
|
|
// BFloat16 is stored as 16-bit (2 bytes) little-endian uint16 on the wire.
|
|
func (c *ColBFloat16) DecodeColumn(r *Reader, rows int) error {
|
|
if rows == 0 {
|
|
return nil
|
|
}
|
|
|
|
const size = 2 // BFloat16 is 2 bytes
|
|
data, err := r.ReadRaw(size * rows)
|
|
if err != nil {
|
|
return errors.Wrap(err, "decode-column")
|
|
}
|
|
v := *c
|
|
for i := 0; i <= len(data)-size; i += size {
|
|
v = append(v, binary.LittleEndian.Uint16(data[i:i+size]))
|
|
}
|
|
*c = v
|
|
return nil
|
|
}
|
|
|
|
// EncodeColumn encodes the BFloat16 rows into given buffer.
|
|
// BFloat16 is written as 16-bit (2 bytes) little-endian uint16.
|
|
func (c ColBFloat16) EncodeColumn(buf *Buffer) {
|
|
v := c
|
|
if len(v) == 0 {
|
|
return
|
|
}
|
|
|
|
const size = 2 // BFloat16 is 2 bytes
|
|
offset := len(buf.Buf)
|
|
|
|
// allocate enough space to fit encoded BFloat16
|
|
buf.Buf = append(buf.Buf, make([]byte, size*len(v))...)
|
|
|
|
for _, vv := range v {
|
|
binary.LittleEndian.PutUint16(buf.Buf[offset:offset+size], vv)
|
|
offset += size
|
|
}
|
|
}
|
|
|
|
// WriteColumn encodes the column data and chains it to w for later writing.
|
|
// The data is added to w's internal buffer vector and will be written
|
|
// when [Writer.Flush] is called. This enables efficient vector I/O by
|
|
// avoiding memory copies.
|
|
func (c ColBFloat16) WriteColumn(w *Writer) {
|
|
w.ChainBuffer(c.EncodeColumn)
|
|
}
|