| 139 | } |
| 140 | |
| 141 | func (encoder *Encoder) encodeRowCols(loc *time.Location, numCols, notNullIdx int) error { |
| 142 | r := &encoder.row |
| 143 | var errs error |
| 144 | for i := range notNullIdx { |
| 145 | d := encoder.values[i] |
| 146 | var err error |
| 147 | r.data, err = encodeValueDatum(loc, d, r.data) |
| 148 | if err != nil { |
| 149 | errs = multierr.Append(errs, err) |
| 150 | } |
| 151 | // handle convert to large |
| 152 | if len(r.data) > math.MaxUint16 && !r.large() { |
| 153 | r.initColIDs32() |
| 154 | for j := range numCols { |
| 155 | r.colIDs32[j] = uint32(r.colIDs[j]) |
| 156 | } |
| 157 | r.initOffsets32() |
| 158 | for j := 0; j <= i; j++ { |
| 159 | r.offsets32[j] = uint32(r.offsets[j]) |
| 160 | } |
| 161 | r.flags |= rowFlagLarge |
| 162 | } |
| 163 | if r.large() { |
| 164 | r.offsets32[i] = uint32(len(r.data)) |
| 165 | } else { |
| 166 | r.offsets[i] = uint16(len(r.data)) |
| 167 | } |
| 168 | } |
| 169 | return errs |
| 170 | } |
| 171 | |
| 172 | // encodeValueDatum encodes one row datum entry into bytes. |
| 173 | // due to encode as value, this method will flatten value type like tablecodec.flatten |