Compare implements the Datum interface.
(ctx *EvalContext, other Datum)
| 766 | |
| 767 | // Compare implements the Datum interface. |
| 768 | func (d *DFloat) Compare(ctx *EvalContext, other Datum) int { |
| 769 | if other == DNull { |
| 770 | // NULL is less than any non-NULL value. |
| 771 | return 1 |
| 772 | } |
| 773 | var v DFloat |
| 774 | switch t := UnwrapDatum(ctx, other).(type) { |
| 775 | case *DFloat: |
| 776 | v = *t |
| 777 | case *DInt: |
| 778 | v = DFloat(MustBeDInt(t)) |
| 779 | case *DDecimal: |
| 780 | return -t.Compare(ctx, d) |
| 781 | default: |
| 782 | panic(makeUnsupportedComparisonMessage(d, other)) |
| 783 | } |
| 784 | if *d < v { |
| 785 | return -1 |
| 786 | } |
| 787 | if *d > v { |
| 788 | return 1 |
| 789 | } |
| 790 | // NaN sorts before non-NaN (#10109). |
| 791 | if *d == v { |
| 792 | return 0 |
| 793 | } |
| 794 | if math.IsNaN(float64(*d)) { |
| 795 | if math.IsNaN(float64(v)) { |
| 796 | return 0 |
| 797 | } |
| 798 | return -1 |
| 799 | } |
| 800 | return 1 |
| 801 | } |
| 802 | |
| 803 | // Prev implements the Datum interface. |
| 804 | func (d *DFloat) Prev(_ *EvalContext) (Datum, bool) { |
nothing calls this directly
no test coverage detected