(b []byte, vals []types.Datum, comparable1 bool)
| 62 | ) |
| 63 | |
| 64 | func preRealloc(b []byte, vals []types.Datum, comparable1 bool) []byte { |
| 65 | var size int |
| 66 | for i := range vals { |
| 67 | switch vals[i].Kind() { |
| 68 | case types.KindInt64, types.KindUint64, types.KindMysqlEnum, types.KindMysqlSet, types.KindMysqlBit, types.KindBinaryLiteral: |
| 69 | size += sizeInt(comparable1) |
| 70 | case types.KindString, types.KindBytes: |
| 71 | size += sizeBytes(vals[i].GetBytes(), comparable1) |
| 72 | case types.KindMysqlTime, types.KindMysqlDuration, types.KindFloat32, types.KindFloat64: |
| 73 | size += 9 |
| 74 | case types.KindNull, types.KindMinNotNull, types.KindMaxValue: |
| 75 | size++ |
| 76 | case types.KindMysqlJSON: |
| 77 | size += 2 + len(vals[i].GetBytes()) |
| 78 | case types.KindVectorFloat32: |
| 79 | size += 1 + vals[i].GetVectorFloat32().SerializedSize() |
| 80 | case types.KindMysqlDecimal: |
| 81 | size += 1 + types.MyDecimalStructSize |
| 82 | default: |
| 83 | return b |
| 84 | } |
| 85 | } |
| 86 | return reallocBytes(b, size) |
| 87 | } |
| 88 | |
| 89 | // encode will encode a datum and append it to a byte slice. If comparable1 is true, the encoded bytes can be sorted as it's original order. |
| 90 | // If hash is true, the encoded bytes can be checked equal as it's original value. |
no test coverage detected