aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/ClickHouse/ch-go/proto/profile.go
blob: 12ca4419d8dcd8eb3d5e5bf5f9b029f32d1aa86c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package proto

import "github.com/go-faster/errors"

type Profile struct {
	Rows                      uint64
	Blocks                    uint64
	Bytes                     uint64
	AppliedLimit              bool
	RowsBeforeLimit           uint64
	CalculatedRowsBeforeLimit bool
}

func (p *Profile) DecodeAware(r *Reader, _ int) error {
	{
		v, err := r.UVarInt()
		if err != nil {
			return errors.Wrap(err, "rows")
		}
		p.Rows = v
	}
	{
		v, err := r.UVarInt()
		if err != nil {
			return errors.Wrap(err, "blocks")
		}
		p.Blocks = v
	}
	{
		v, err := r.UVarInt()
		if err != nil {
			return errors.Wrap(err, "bytes")
		}
		p.Bytes = v
	}
	{
		v, err := r.Bool()
		if err != nil {
			return errors.Wrap(err, "applied limit")
		}
		p.AppliedLimit = v
	}
	{
		v, err := r.UVarInt()
		if err != nil {
			return errors.Wrap(err, "rows before limit")
		}
		p.RowsBeforeLimit = v
	}
	{
		v, err := r.Bool()
		if err != nil {
			return errors.Wrap(err, "calculated rows before limit")
		}
		p.CalculatedRowsBeforeLimit = v
	}

	return nil
}

func (p Profile) EncodeAware(b *Buffer, _ int) {
	ServerCodeProfile.Encode(b)
	b.PutUVarInt(p.Rows)
	b.PutUVarInt(p.Blocks)
	b.PutUVarInt(p.Bytes)
	b.PutBool(p.AppliedLimit)
	b.PutUVarInt(p.RowsBeforeLimit)
	b.PutBool(p.CalculatedRowsBeforeLimit)
}