| 91 | } |
| 92 | |
| 93 | func (encoder *Encoder) reformatCols() (numCols, notNullIdx int) { |
| 94 | r := &encoder.row |
| 95 | numCols = len(encoder.tempColIDs) |
| 96 | nullIdx := numCols - int(r.numNullCols) |
| 97 | notNullIdx = 0 |
| 98 | if r.large() { |
| 99 | r.initColIDs32() |
| 100 | r.initOffsets32() |
| 101 | } else { |
| 102 | r.initColIDs() |
| 103 | r.initOffsets() |
| 104 | } |
| 105 | for i, colID := range encoder.tempColIDs { |
| 106 | if encoder.values[i].IsNull() { |
| 107 | if r.large() { |
| 108 | r.colIDs32[nullIdx] = uint32(colID) |
| 109 | } else { |
| 110 | r.colIDs[nullIdx] = byte(colID) |
| 111 | } |
| 112 | nullIdx++ |
| 113 | } else { |
| 114 | if r.large() { |
| 115 | r.colIDs32[notNullIdx] = uint32(colID) |
| 116 | } else { |
| 117 | r.colIDs[notNullIdx] = byte(colID) |
| 118 | } |
| 119 | encoder.values[notNullIdx] = encoder.values[i] |
| 120 | notNullIdx++ |
| 121 | } |
| 122 | } |
| 123 | if r.large() { |
| 124 | largeNotNullSorter := (*largeNotNullSorter)(encoder) |
| 125 | sort.Sort(largeNotNullSorter) |
| 126 | if r.numNullCols > 0 { |
| 127 | largeNullSorter := (*largeNullSorter)(encoder) |
| 128 | sort.Sort(largeNullSorter) |
| 129 | } |
| 130 | } else { |
| 131 | smallNotNullSorter := (*smallNotNullSorter)(encoder) |
| 132 | sort.Sort(smallNotNullSorter) |
| 133 | if r.numNullCols > 0 { |
| 134 | smallNullSorter := (*smallNullSorter)(encoder) |
| 135 | sort.Sort(smallNullSorter) |
| 136 | } |
| 137 | } |
| 138 | return |
| 139 | } |
| 140 | |
| 141 | func (encoder *Encoder) encodeRowCols(loc *time.Location, numCols, notNullIdx int) error { |
| 142 | r := &encoder.row |