| 309 | namespace { |
| 310 | |
| 311 | static Result<std::shared_ptr<Scalar>> MakeScalarForRunEndValue( |
| 312 | const DataType& run_end_type, int64_t run_end) { |
| 313 | switch (run_end_type.id()) { |
| 314 | case Type::INT16: |
| 315 | if (run_end > std::numeric_limits<int16_t>::max()) { |
| 316 | return Status::Invalid("Array construction with int16 run end type cannot fit ", |
| 317 | run_end); |
| 318 | } |
| 319 | return std::make_shared<Int16Scalar>(static_cast<int16_t>(run_end)); |
| 320 | case Type::INT32: |
| 321 | if (run_end > std::numeric_limits<int32_t>::max()) { |
| 322 | return Status::Invalid("Array construction with int32 run end type cannot fit ", |
| 323 | run_end); |
| 324 | } |
| 325 | return std::make_shared<Int32Scalar>(static_cast<int32_t>(run_end)); |
| 326 | default: |
| 327 | break; |
| 328 | } |
| 329 | DCHECK_EQ(run_end_type.id(), Type::INT64); |
| 330 | return std::make_shared<Int64Scalar>(run_end); |
| 331 | } |
| 332 | |
| 333 | // get the maximum buffer length required, then allocate a single zeroed buffer |
| 334 | // to use anywhere a buffer is required |