| 286 | } |
| 287 | |
| 288 | void RowEncoder::Init(const std::vector<TypeHolder>& column_types, ExecContext* ctx) { |
| 289 | ctx_ = ctx; |
| 290 | encoders_.resize(column_types.size()); |
| 291 | extension_types_.resize(column_types.size()); |
| 292 | |
| 293 | for (size_t i = 0; i < column_types.size(); ++i) { |
| 294 | const bool is_extension = column_types[i].id() == Type::EXTENSION; |
| 295 | const TypeHolder& type = |
| 296 | is_extension |
| 297 | ? arrow::internal::checked_cast<const ExtensionType*>(column_types[i].type) |
| 298 | ->storage_type() |
| 299 | : column_types[i]; |
| 300 | |
| 301 | if (is_extension) { |
| 302 | extension_types_[i] = arrow::internal::checked_pointer_cast<ExtensionType>( |
| 303 | column_types[i].GetSharedPtr()); |
| 304 | } |
| 305 | if (type.id() == Type::BOOL) { |
| 306 | encoders_[i] = std::make_shared<BooleanKeyEncoder>(); |
| 307 | continue; |
| 308 | } |
| 309 | |
| 310 | if (type.id() == Type::DICTIONARY) { |
| 311 | encoders_[i] = |
| 312 | std::make_shared<DictionaryKeyEncoder>(type.GetSharedPtr(), ctx->memory_pool()); |
| 313 | continue; |
| 314 | } |
| 315 | |
| 316 | if (is_fixed_width(type.id())) { |
| 317 | encoders_[i] = std::make_shared<FixedWidthKeyEncoder>(type.GetSharedPtr()); |
| 318 | continue; |
| 319 | } |
| 320 | |
| 321 | if (is_binary_like(type.id())) { |
| 322 | encoders_[i] = |
| 323 | std::make_shared<VarLengthKeyEncoder<BinaryType>>(type.GetSharedPtr()); |
| 324 | continue; |
| 325 | } |
| 326 | |
| 327 | if (is_large_binary_like(type.id())) { |
| 328 | encoders_[i] = |
| 329 | std::make_shared<VarLengthKeyEncoder<LargeBinaryType>>(type.GetSharedPtr()); |
| 330 | continue; |
| 331 | } |
| 332 | |
| 333 | if (is_binary_view_like(type.id())) { |
| 334 | encoders_[i] = std::make_shared<BinaryViewKeyEncoder>(type.GetSharedPtr()); |
| 335 | continue; |
| 336 | } |
| 337 | |
| 338 | // We should not get here |
| 339 | ARROW_DCHECK(false); |
| 340 | } |
| 341 | |
| 342 | int32_t total_length = 0; |
| 343 | for (size_t i = 0; i < column_types.size(); ++i) { |
| 344 | encoders_[i]->AddLengthNull(&total_length); |
| 345 | } |
nothing calls this directly
no test coverage detected