| 2439 | } |
| 2440 | |
| 2441 | Result<std::shared_ptr<SparseIndex>> ReadSparseCSFIndex( |
| 2442 | const flatbuf::SparseTensor* sparse_tensor, const std::vector<int64_t>& shape, |
| 2443 | io::RandomAccessFile* file) { |
| 2444 | auto* sparse_index = sparse_tensor->sparseIndex_as_SparseTensorIndexCSF(); |
| 2445 | const auto ndim = static_cast<int64_t>(shape.size()); |
| 2446 | RETURN_NOT_OK(ValidateSparseCSFIndexMetadata(sparse_index, ndim)); |
| 2447 | auto* indptr_buffers = sparse_index->indptrBuffers(); |
| 2448 | auto* indices_buffers = sparse_index->indicesBuffers(); |
| 2449 | std::vector<std::shared_ptr<Buffer>> indptr_data(ndim - 1); |
| 2450 | std::vector<std::shared_ptr<Buffer>> indices_data(ndim); |
| 2451 | |
| 2452 | std::shared_ptr<DataType> indptr_type, indices_type; |
| 2453 | std::vector<int64_t> axis_order, indices_size; |
| 2454 | |
| 2455 | RETURN_NOT_OK(internal::GetSparseCSFIndexMetadata( |
| 2456 | sparse_index, &axis_order, &indices_size, &indptr_type, &indices_type)); |
| 2457 | for (int i = 0; i < static_cast<int>(indptr_buffers->size()); ++i) { |
| 2458 | ARROW_ASSIGN_OR_RAISE(indptr_data[i], file->ReadAt(indptr_buffers->Get(i)->offset(), |
| 2459 | indptr_buffers->Get(i)->length(), |
| 2460 | /*allow_short_read=*/false)); |
| 2461 | } |
| 2462 | for (int i = 0; i < static_cast<int>(indices_buffers->size()); ++i) { |
| 2463 | ARROW_ASSIGN_OR_RAISE(indices_data[i], file->ReadAt(indices_buffers->Get(i)->offset(), |
| 2464 | indices_buffers->Get(i)->length(), |
| 2465 | /*allow_short_read=*/false)); |
| 2466 | } |
| 2467 | |
| 2468 | return SparseCSFIndex::Make(indptr_type, indices_type, indices_size, axis_order, |
| 2469 | indptr_data, indices_data); |
| 2470 | } |
| 2471 | |
| 2472 | Result<std::shared_ptr<SparseTensor>> MakeSparseTensorWithSparseCOOIndex( |
| 2473 | const std::shared_ptr<DataType>& type, const std::vector<int64_t>& shape, |
no test coverage detected