Next implements the Datum interface.
(ctx context.Context, cmpCtx CompareContext)
| 4646 | |
| 4647 | // Next implements the Datum interface. |
| 4648 | func (d *DTuple) Next(ctx context.Context, cmpCtx CompareContext) (Datum, bool) { |
| 4649 | // Note: (a:decimal, b:int, c:int) has a next value; that's (a, b, |
| 4650 | // c+1). With an exception if c is MaxInt64, in which case the next |
| 4651 | // value is (a, b+1, min(_ *EvalContext)). However, (a:int, b:decimal) does not |
| 4652 | // have a next value, because decimal doesn't have one. |
| 4653 | // |
| 4654 | // In general, a tuple has a next value if and only if it ends with |
| 4655 | // zero or more values that are a maximum and a minimum value of the |
| 4656 | // same type exists, and the first element before that has a next |
| 4657 | // value. |
| 4658 | res := NewDTupleWithLen(d.typ, len(d.D)) |
| 4659 | copy(res.D, d.D) |
| 4660 | for i := len(res.D) - 1; i >= 0; i-- { |
| 4661 | if !res.D[i].IsMax(ctx, cmpCtx) { |
| 4662 | nextVal, ok := res.D[i].Next(ctx, cmpCtx) |
| 4663 | if !ok { |
| 4664 | return nil, false |
| 4665 | } |
| 4666 | res.D[i] = nextVal |
| 4667 | break |
| 4668 | } |
| 4669 | // TODO(#12022): temporary workaround; see the interface comment. |
| 4670 | res.D[i] = DNull |
| 4671 | } |
| 4672 | return res, true |
| 4673 | } |
| 4674 | |
| 4675 | // Max implements the Datum interface. |
| 4676 | func (d *DTuple) Max(ctx context.Context, cmpCtx CompareContext) (Datum, bool) { |
nothing calls this directly
no test coverage detected