File tree 3 files changed +34
-22
lines changed
3 files changed +34
-22
lines changed Original file line number Diff line number Diff line change @@ -10,25 +10,20 @@ type count struct {
10
10
}
11
11
12
12
func (a * count ) Consume (vec vector.Any ) {
13
- if c , ok := vec .(* vector.Const ); ok {
14
- val := c .Value ()
15
- if ! val .IsNull () && ! val .IsError () {
16
- a .count += uint64 (vec .Len ())
17
- }
13
+ if c , ok := vec .(* vector.Const ); ok && c .Value ().IsNull () {
18
14
return
19
15
}
20
16
if _ , ok := vector .Under (vec ).Type ().(* super.TypeError ); ok {
21
17
return
22
18
}
23
- nulls := vector .NullsOf (vec )
24
- if nulls == nil {
25
- a .count += uint64 (vec .Len ())
26
- return
27
- }
28
- for i := range vec .Len () {
29
- if ! nulls .Value (i ) {
30
- a .count ++
19
+ if nulls := vector .NullsOf (vec ); nulls != nil {
20
+ for i := range vec .Len () {
21
+ if ! nulls .Value (i ) {
22
+ a .count ++
23
+ }
31
24
}
25
+ } else {
26
+ a .count += uint64 (vec .Len ())
32
27
}
33
28
}
34
29
Original file line number Diff line number Diff line change @@ -41,15 +41,15 @@ func (a *Aggregator) Eval(this vector.Any) vector.Any {
41
41
42
42
func (a * Aggregator ) apply (args ... vector.Any ) vector.Any {
43
43
vec , where := args [0 ], args [1 ]
44
- var tags []uint32
45
- // If type is not bool then we want to filter everything.
46
- if where .Type ().ID () == super .IDBool {
47
- for slot := uint32 (0 ); slot < where .Len (); slot ++ {
48
- // XXX Feels like we should have a optimzed version of this.
49
- if vector .BoolValue (where , slot ) {
50
- tags = append (tags , slot )
51
- }
44
+ bools , _ := BoolMask (where )
45
+ bools .Flip (0 , uint64 (vec .Len ()))
46
+ if ! bools .IsEmpty () {
47
+ nulls := vector .NewBoolEmpty (vec .Len (), nil )
48
+ bools .WriteDenseTo (nulls .Bits )
49
+ if origNulls := vector .NullsOf (vec ); origNulls != nil {
50
+ nulls = vector .Or (nulls , origNulls )
52
51
}
52
+ vector .SetNulls (vec , nulls )
53
53
}
54
- return vector . NewView ( vec , tags )
54
+ return vec
55
55
}
Original file line number Diff line number Diff line change
1
+ zed : |
2
+ summarize
3
+ num_requests := count()
4
+ where log_time >= 2012-10-01T00:00:00Z
5
+ by client_ip
6
+ | sort client_ip
7
+
8
+ vector : true
9
+
10
+ input : |
11
+ {log_time:2012-01-01T00:00:44Z,client_ip:249.92.17.134}
12
+ {log_time:2012-10-01T00:24:30Z,client_ip:249.92.17.134}
13
+ {log_time:2012-05-12T10:23:22Z,client_ip:251.58.48.137}
14
+
15
+ output : |
16
+ {client_ip:249.92.17.134,num_requests:1(uint64)}
17
+ {client_ip:251.58.48.137,num_requests:0(uint64)}
You can’t perform that action at this time.
0 commit comments