| 151 | } |
| 152 | |
| 153 | Status RowTableEncoder::EncodeSelected(RowTableImpl* rows, uint32_t num_selected, |
| 154 | const uint16_t* selection) { |
| 155 | rows->Clean(); |
| 156 | |
| 157 | // First AppendEmpty with num_selected rows and zero extra bytes to resize the |
| 158 | // fixed-length buffers (including buffer for offsets). |
| 159 | RETURN_NOT_OK( |
| 160 | rows->AppendEmpty(static_cast<uint32_t>(num_selected), |
| 161 | /*num_extra_bytes_to_append=*/static_cast<uint32_t>(0))); |
| 162 | // Then populate the offsets of the var-length columns, which will be used as the target |
| 163 | // size of the var-length buffers resizing below. |
| 164 | RETURN_NOT_OK(EncoderOffsets::GetRowOffsetsSelected(rows, batch_varbinary_cols_, |
| 165 | num_selected, selection)); |
| 166 | // Last AppendEmpty with zero rows and zero extra bytes to resize the var-length buffers |
| 167 | // based on the populated offsets. |
| 168 | RETURN_NOT_OK( |
| 169 | rows->AppendEmpty(/*num_rows_to_append=*/static_cast<uint32_t>(0), |
| 170 | /*num_extra_bytes_to_append=*/static_cast<uint32_t>(0))); |
| 171 | |
| 172 | for (size_t icol = 0; icol < batch_all_cols_.size(); ++icol) { |
| 173 | if (batch_all_cols_[icol].metadata().is_fixed_length) { |
| 174 | uint32_t offset_within_row = rows->metadata().column_offsets[icol]; |
| 175 | EncoderBinary::EncodeSelected(offset_within_row, rows, batch_all_cols_[icol], |
| 176 | num_selected, selection); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | EncoderOffsets::EncodeSelected(rows, batch_varbinary_cols_, num_selected, selection); |
| 181 | |
| 182 | for (size_t icol = 0; icol < batch_varbinary_cols_.size(); ++icol) { |
| 183 | EncoderVarBinary::EncodeSelected(static_cast<uint32_t>(icol), rows, |
| 184 | batch_varbinary_cols_[icol], num_selected, |
| 185 | selection); |
| 186 | } |
| 187 | |
| 188 | EncoderNulls::EncodeSelected(rows, batch_all_cols_, num_selected, selection); |
| 189 | |
| 190 | return Status::OK(); |
| 191 | } |
| 192 | |
| 193 | namespace { |
| 194 | struct TransformBoolean { |