Compare implements the Datum interface.
(ctx context.Context, cmpCtx CompareContext, other Datum)
| 5067 | |
| 5068 | // Compare implements the Datum interface. |
| 5069 | func (d *DArray) Compare(ctx context.Context, cmpCtx CompareContext, other Datum) (int, error) { |
| 5070 | if other == DNull { |
| 5071 | // NULL is less than any non-NULL value. |
| 5072 | return 1, nil |
| 5073 | } |
| 5074 | v, ok := cmpCtx.UnwrapDatum(ctx, other).(*DArray) |
| 5075 | if !ok { |
| 5076 | return 0, makeUnsupportedComparisonMessage(d, other) |
| 5077 | } |
| 5078 | n := d.Len() |
| 5079 | if n > v.Len() { |
| 5080 | n = v.Len() |
| 5081 | } |
| 5082 | for i := 0; i < n; i++ { |
| 5083 | c, err := d.Array[i].Compare(ctx, cmpCtx, v.Array[i]) |
| 5084 | if err != nil { |
| 5085 | return 0, err |
| 5086 | } |
| 5087 | if c != 0 { |
| 5088 | return c, nil |
| 5089 | } |
| 5090 | } |
| 5091 | if d.Len() < v.Len() { |
| 5092 | return -1, nil |
| 5093 | } |
| 5094 | if d.Len() > v.Len() { |
| 5095 | return 1, nil |
| 5096 | } |
| 5097 | return 0, nil |
| 5098 | } |
| 5099 | |
| 5100 | // Prev implements the Datum interface. |
| 5101 | func (d *DArray) Prev(ctx context.Context, cmpCtx CompareContext) (Datum, bool) { |
nothing calls this directly
no test coverage detected