Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
kshvakov committed Aug 23, 2017
1 parent f0b5324 commit ca76823
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Golang SQL database driver for [Yandex ClickHouse](https://clickhouse.yandex/)
* no_delay - disable/enable the Nagle Algorithm for tcp socket (default is 'true' - disable)
* alt_hosts - comma separated list of single address host for load-balancing
* connection_open_strategy - random/in_order (default random).
* random - always try to open a new connection with a random host
* in_order - use only for failover, host will be chosen by order priority
* random - choose random server from set
* in_order - first live server is choosen in specified order
* block_size - maximum rows in block (default is 1000000). If the rows are larger then the data will be split into several blocks to send them to the server
* debug - enable debug output (boolean value)

Expand Down
28 changes: 17 additions & 11 deletions lib/binary/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func NewDecoder(input io.Reader) *Decoder {

type Decoder struct {
input io.Reader
scratch [16]byte
scratch [binary.MaxVarintLen64]byte
}

func (decoder *Decoder) Bool() (bool, error) {
Expand Down Expand Up @@ -70,28 +70,34 @@ func (decoder *Decoder) UInt8() (uint8, error) {
}

func (decoder *Decoder) UInt16() (uint16, error) {
buf := decoder.scratch[:2]
if _, err := decoder.input.Read(buf); err != nil {
if _, err := decoder.input.Read(decoder.scratch[:2]); err != nil {
return 0, err
}
return uint16(buf[0]) | uint16(buf[1])<<8, nil
return uint16(decoder.scratch[0]) | uint16(decoder.scratch[1])<<8, nil
}

func (decoder *Decoder) UInt32() (uint32, error) {
buf := decoder.scratch[:4]
if _, err := decoder.input.Read(buf); err != nil {
if _, err := decoder.input.Read(decoder.scratch[:4]); err != nil {
return 0, err
}
return uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24, nil
return uint32(decoder.scratch[0]) |
uint32(decoder.scratch[1])<<8 |
uint32(decoder.scratch[2])<<16 |
uint32(decoder.scratch[3])<<24, nil
}

func (decoder *Decoder) UInt64() (uint64, error) {
buf := decoder.scratch[:8]
if _, err := decoder.input.Read(buf); err != nil {
if _, err := decoder.input.Read(decoder.scratch[:8]); err != nil {
return 0, err
}
return uint64(buf[0]) | uint64(buf[1])<<8 | uint64(buf[2])<<16 | uint64(buf[3])<<24 |
uint64(buf[4])<<32 | uint64(buf[5])<<40 | uint64(buf[6])<<48 | uint64(buf[7])<<56, nil
return uint64(decoder.scratch[0]) |
uint64(decoder.scratch[1])<<8 |
uint64(decoder.scratch[2])<<16 |
uint64(decoder.scratch[3])<<24 |
uint64(decoder.scratch[4])<<32 |
uint64(decoder.scratch[5])<<40 |
uint64(decoder.scratch[6])<<48 |
uint64(decoder.scratch[7])<<56, nil
}

func (decoder *Decoder) Float32() (float32, error) {
Expand Down
2 changes: 1 addition & 1 deletion lib/binary/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NewEncoder(output io.Writer) *Encoder {

type Encoder struct {
output io.Writer
scratch [16]byte
scratch [binary.MaxVarintLen64]byte
}

func (enc *Encoder) Uvarint(v uint64) error {
Expand Down

0 comments on commit ca76823

Please sign in to comment.