Next implements the Datum interface.
(ctx *EvalContext)
| 2999 | |
| 3000 | // Next implements the Datum interface. |
| 3001 | func (d *DTuple) Next(ctx *EvalContext) (Datum, bool) { |
| 3002 | // Note: (a:decimal, b:int, c:int) has a next value; that's (a, b, |
| 3003 | // c+1). With an exception if c is MaxInt64, in which case the next |
| 3004 | // value is (a, b+1, min(_ *EvalContext)). However, (a:int, b:decimal) does not |
| 3005 | // have a next value, because decimal doesn't have one. |
| 3006 | // |
| 3007 | // In general, a tuple has a next value if and only if it ends with |
| 3008 | // zero or more values that are a maximum and a minimum value of the |
| 3009 | // same type exists, and the first element before that has a next |
| 3010 | // value. |
| 3011 | res := NewDTupleWithLen(d.typ, len(d.D)) |
| 3012 | copy(res.D, d.D) |
| 3013 | for i := len(res.D) - 1; i >= 0; i-- { |
| 3014 | if !res.D[i].IsMax(ctx) { |
| 3015 | nextVal, ok := res.D[i].Next(ctx) |
| 3016 | if !ok { |
| 3017 | return nil, false |
| 3018 | } |
| 3019 | res.D[i] = nextVal |
| 3020 | break |
| 3021 | } |
| 3022 | // TODO(#12022): temporary workaround; see the interface comment. |
| 3023 | res.D[i] = DNull |
| 3024 | } |
| 3025 | return res, true |
| 3026 | } |
| 3027 | |
| 3028 | // Max implements the Datum interface. |
| 3029 | func (d *DTuple) Max(ctx *EvalContext) (Datum, bool) { |
nothing calls this directly
no test coverage detected