(args ...vector.Any)
| 31 | } |
| 32 | |
| 33 | func (b *Bucket) call(args ...vector.Any) vector.Any { |
| 34 | if vec, ok := expr.CheckForNullThenError(args); ok { |
| 35 | return vec |
| 36 | } |
| 37 | tsArg, binArg := args[0], args[1] |
| 38 | if _, ok := binArg.(*vector.Const); ok { |
| 39 | bin := vector.IntValue(binArg, 0) |
| 40 | return b.constBin(tsArg, nano.Duration(bin)) |
| 41 | } |
| 42 | var ints []int64 |
| 43 | for i := range tsArg.Len() { |
| 44 | dur := vector.IntValue(tsArg, i) |
| 45 | bin := vector.IntValue(binArg, i) |
| 46 | if bin == 0 { |
| 47 | ints = append(ints, dur) |
| 48 | } else { |
| 49 | ints = append(ints, int64(nano.Ts(dur).Trunc(nano.Duration(bin)))) |
| 50 | } |
| 51 | } |
| 52 | return vector.NewInt(b.resultType(tsArg), ints) |
| 53 | } |
| 54 | |
| 55 | func (b *Bucket) constBin(tsVec vector.Any, bin nano.Duration) vector.Any { |
| 56 | if bin == 0 { |
nothing calls this directly
no test coverage detected