(buffer *ByteBuffer, scale int32, unscaled *big.Int)
| 99 | } |
| 100 | |
| 101 | func writeDecimalParts(buffer *ByteBuffer, scale int32, unscaled *big.Int) { |
| 102 | if unscaled == nil { |
| 103 | unscaled = new(big.Int) |
| 104 | } |
| 105 | buffer.WriteVarint32(scale) |
| 106 | if canUseSmallDecimalEncoding(unscaled) { |
| 107 | smallValue := unscaled.Int64() |
| 108 | header := encodeDecimalZigZag64(smallValue) << 1 |
| 109 | buffer.WriteVarUint64(header) |
| 110 | return |
| 111 | } |
| 112 | |
| 113 | abs := new(big.Int).Abs(unscaled) |
| 114 | magnitudeBytes := abs.Bytes() |
| 115 | if len(magnitudeBytes) == 0 { |
| 116 | panic("decimal zero must use the small encoding") |
| 117 | } |
| 118 | reverseBytes(magnitudeBytes) |
| 119 | meta := (uint64(len(magnitudeBytes)) << 1) | uint64(signBit(unscaled.Sign())) |
| 120 | buffer.WriteVarUint64((meta << 1) | 1) |
| 121 | buffer.WriteBinary(magnitudeBytes) |
| 122 | } |
| 123 | |
| 124 | func readDecimalParts(ctx *ReadContext) (int32, *big.Int) { |
| 125 | err := ctx.Err() |
no test coverage detected