| 273 | /// @{ |
| 274 | |
| 275 | struct ExecValue { |
| 276 | ArraySpan array = {}; |
| 277 | const Scalar* scalar = NULLPTR; |
| 278 | |
| 279 | ExecValue(const Scalar* scalar) // NOLINT implicit conversion |
| 280 | : scalar(scalar) {} |
| 281 | |
| 282 | ExecValue(ArraySpan array) // NOLINT implicit conversion |
| 283 | : array(std::move(array)) {} |
| 284 | |
| 285 | ExecValue(const ArrayData& array) { // NOLINT implicit conversion |
| 286 | this->array.SetMembers(array); |
| 287 | } |
| 288 | |
| 289 | ExecValue() = default; |
| 290 | ExecValue(const ExecValue& other) = default; |
| 291 | ExecValue& operator=(const ExecValue& other) = default; |
| 292 | ExecValue(ExecValue&& other) = default; |
| 293 | ExecValue& operator=(ExecValue&& other) = default; |
| 294 | |
| 295 | int64_t length() const { return this->is_array() ? this->array.length : 1; } |
| 296 | |
| 297 | bool is_array() const { return this->scalar == NULLPTR; } |
| 298 | bool is_scalar() const { return !this->is_array(); } |
| 299 | |
| 300 | void SetArray(const ArrayData& array) { |
| 301 | this->array.SetMembers(array); |
| 302 | this->scalar = NULLPTR; |
| 303 | } |
| 304 | |
| 305 | void SetScalar(const Scalar* scalar) { this->scalar = scalar; } |
| 306 | |
| 307 | template <typename ExactType> |
| 308 | const ExactType& scalar_as() const { |
| 309 | return ::arrow::internal::checked_cast<const ExactType&>(*this->scalar); |
| 310 | } |
| 311 | |
| 312 | /// XXX: here temporarily for compatibility with datum, see |
| 313 | /// e.g. MakeStructExec in scalar_nested.cc |
| 314 | int64_t null_count() const { |
| 315 | if (this->is_array()) { |
| 316 | return this->array.GetNullCount(); |
| 317 | } else { |
| 318 | return this->scalar->is_valid ? 0 : 1; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | const DataType* type() const { |
| 323 | if (this->is_array()) { |
| 324 | return array.type; |
| 325 | } else { |
| 326 | return scalar->type.get(); |
| 327 | } |
| 328 | } |
| 329 | }; |
| 330 | |
| 331 | struct ARROW_EXPORT ExecResult { |
| 332 | // The default value of the variant is ArraySpan |
no outgoing calls
no test coverage detected