| 364 | } |
| 365 | |
| 366 | Result<std::shared_ptr<DataType>> FixedShapeTensorType::Make( |
| 367 | const std::shared_ptr<DataType>& value_type, const std::vector<int64_t>& shape, |
| 368 | const std::vector<int64_t>& permutation, const std::vector<std::string>& dim_names) { |
| 369 | const size_t ndim = shape.size(); |
| 370 | for (auto dim : shape) { |
| 371 | if (dim < 0) { |
| 372 | return Status::Invalid("shape must have non-negative values, got ", dim); |
| 373 | } |
| 374 | } |
| 375 | if (!permutation.empty() && ndim != permutation.size()) { |
| 376 | return Status::Invalid("permutation size must match shape size. Expected: ", ndim, |
| 377 | " Got: ", permutation.size()); |
| 378 | } |
| 379 | if (!dim_names.empty() && ndim != dim_names.size()) { |
| 380 | return Status::Invalid("dim_names size must match shape size. Expected: ", ndim, |
| 381 | " Got: ", dim_names.size()); |
| 382 | } |
| 383 | if (!permutation.empty()) { |
| 384 | RETURN_NOT_OK(internal::IsPermutationValid(permutation)); |
| 385 | } |
| 386 | |
| 387 | ARROW_ASSIGN_OR_RAISE(const int64_t size, internal::ComputeShapeProduct(shape)); |
| 388 | if (size > std::numeric_limits<int32_t>::max()) { |
| 389 | return Status::Invalid("Product of shape dimensions (", size, |
| 390 | ") exceeds maximum FixedSizeList size (", |
| 391 | std::numeric_limits<int32_t>::max(), ")"); |
| 392 | } |
| 393 | return std::make_shared<FixedShapeTensorType>(value_type, static_cast<int32_t>(size), |
| 394 | shape, permutation, dim_names); |
| 395 | } |
| 396 | |
| 397 | const std::vector<int64_t>& FixedShapeTensorType::strides() { |
| 398 | if (strides_.empty()) { |
nothing calls this directly
no test coverage detected