| 450 | } |
| 451 | |
| 452 | VectorKernel NewModeKernel(const std::shared_ptr<DataType>& in_type, ArrayKernelExec exec, |
| 453 | VectorKernel::ChunkedExec exec_chunked) { |
| 454 | VectorKernel kernel; |
| 455 | kernel.init = ModeState::Init; |
| 456 | kernel.can_execute_chunkwise = false; |
| 457 | kernel.output_chunked = false; |
| 458 | switch (in_type->id()) { |
| 459 | case Type::DECIMAL128: |
| 460 | case Type::DECIMAL256: |
| 461 | kernel.signature = |
| 462 | KernelSignature::Make({InputType(in_type->id())}, OutputType(ModeType)); |
| 463 | break; |
| 464 | default: { |
| 465 | auto out_type = |
| 466 | struct_({field(kModeFieldName, in_type), field(kCountFieldName, int64())}); |
| 467 | kernel.signature = KernelSignature::Make({in_type->id()}, std::move(out_type)); |
| 468 | break; |
| 469 | } |
| 470 | } |
| 471 | kernel.exec = std::move(exec); |
| 472 | kernel.exec_chunked = exec_chunked; |
| 473 | return kernel; |
| 474 | } |
| 475 | |
| 476 | const FunctionDoc mode_doc{ |
| 477 | "Compute the modal (most common) values of a numeric array", |
no test coverage detected