/
aggregation_top_rows.go
55 lines (44 loc) · 1.08 KB
/
aggregation_top_rows.go
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
package search
import (
"github.com/aliyun/aliyun-tablestore-go-sdk/tablestore/otsprotocol"
"github.com/golang/protobuf/proto"
)
type TopRowsAggregation struct {
AggName string
Limit *int32
Sort *Sort
}
func (a *TopRowsAggregation) GetName() string {
return a.AggName
}
func (a *TopRowsAggregation) GetType() AggregationType {
return AggregationTopRowsType
}
func (a *TopRowsAggregation) Serialize() ([]byte, error) {
pbAgg := &otsprotocol.TopRowsAggregation{}
pbAgg.Limit = a.Limit
if a.Sort != nil {
var err error
pbAgg.Sort, err = (*Sort).ProtoBuffer(a.Sort)
if err != nil {
return nil, err
}
}
data, err := proto.Marshal(pbAgg)
return data, err
}
func (a *TopRowsAggregation) ProtoBuffer() (*otsprotocol.Aggregation, error) {
return BuildPBForAggregation(a)
}
func (a *TopRowsAggregation) SetName(name string) *TopRowsAggregation {
a.AggName = name
return a
}
func (a *TopRowsAggregation) SetLimit(limit int32) *TopRowsAggregation {
a.Limit = &limit
return a
}
func (a *TopRowsAggregation) SetSort(sort *Sort) *TopRowsAggregation {
a.Sort = sort
return a
}