Compare implements the Datum interface.
(ctx context.Context, cmpCtx CompareContext, other Datum)
| 851 | |
| 852 | // Compare implements the Datum interface. |
| 853 | func (d *DFloat) Compare(ctx context.Context, cmpCtx CompareContext, other Datum) (int, error) { |
| 854 | if other == DNull { |
| 855 | // NULL is less than any non-NULL value. |
| 856 | return 1, nil |
| 857 | } |
| 858 | var v DFloat |
| 859 | switch t := cmpCtx.UnwrapDatum(ctx, other).(type) { |
| 860 | case *DFloat: |
| 861 | v = *t |
| 862 | case *DInt: |
| 863 | v = DFloat(MustBeDInt(t)) |
| 864 | case *DDecimal: |
| 865 | res, err := t.Compare(ctx, cmpCtx, d) |
| 866 | if err != nil { |
| 867 | return 0, err |
| 868 | } |
| 869 | return -res, nil |
| 870 | default: |
| 871 | return 0, makeUnsupportedComparisonMessage(d, other) |
| 872 | } |
| 873 | if *d < v { |
| 874 | return -1, nil |
| 875 | } |
| 876 | if *d > v { |
| 877 | return 1, nil |
| 878 | } |
| 879 | // NaN sorts before non-NaN (#10109). |
| 880 | if *d == v { |
| 881 | return 0, nil |
| 882 | } |
| 883 | if math.IsNaN(float64(*d)) { |
| 884 | if math.IsNaN(float64(v)) { |
| 885 | return 0, nil |
| 886 | } |
| 887 | return -1, nil |
| 888 | } |
| 889 | return 1, nil |
| 890 | } |
| 891 | |
| 892 | // Prev implements the Datum interface. |
| 893 | func (d *DFloat) Prev(ctx context.Context, cmpCtx CompareContext) (Datum, bool) { |
nothing calls this directly
no test coverage detected