| 2422 | } |
| 2423 | |
| 2424 | Result<std::shared_ptr<SparseIndex>> ReadSparseCSFIndex( |
| 2425 | const flatbuf::SparseTensor* sparse_tensor, const std::vector<int64_t>& shape, |
| 2426 | io::RandomAccessFile* file) { |
| 2427 | auto* sparse_index = sparse_tensor->sparseIndex_as_SparseTensorIndexCSF(); |
| 2428 | const auto ndim = static_cast<int64_t>(shape.size()); |
| 2429 | RETURN_NOT_OK(ValidateSparseCSFIndexMetadata(sparse_index, ndim)); |
| 2430 | auto* indptr_buffers = sparse_index->indptrBuffers(); |
| 2431 | auto* indices_buffers = sparse_index->indicesBuffers(); |
| 2432 | std::vector<std::shared_ptr<Buffer>> indptr_data(ndim - 1); |
| 2433 | std::vector<std::shared_ptr<Buffer>> indices_data(ndim); |
| 2434 | |
| 2435 | std::shared_ptr<DataType> indptr_type, indices_type; |
| 2436 | std::vector<int64_t> axis_order, indices_size; |
| 2437 | |
| 2438 | RETURN_NOT_OK(internal::GetSparseCSFIndexMetadata( |
| 2439 | sparse_index, &axis_order, &indices_size, &indptr_type, &indices_type)); |
| 2440 | for (int i = 0; i < static_cast<int>(indptr_buffers->size()); ++i) { |
| 2441 | ARROW_ASSIGN_OR_RAISE(indptr_data[i], file->ReadAt(indptr_buffers->Get(i)->offset(), |
| 2442 | indptr_buffers->Get(i)->length(), |
| 2443 | /*allow_short_read=*/false)); |
| 2444 | } |
| 2445 | for (int i = 0; i < static_cast<int>(indices_buffers->size()); ++i) { |
| 2446 | ARROW_ASSIGN_OR_RAISE(indices_data[i], file->ReadAt(indices_buffers->Get(i)->offset(), |
| 2447 | indices_buffers->Get(i)->length(), |
| 2448 | /*allow_short_read=*/false)); |
| 2449 | } |
| 2450 | |
| 2451 | return SparseCSFIndex::Make(indptr_type, indices_type, indices_size, axis_order, |
| 2452 | indptr_data, indices_data); |
| 2453 | } |
| 2454 | |
| 2455 | Result<std::shared_ptr<SparseTensor>> MakeSparseTensorWithSparseCOOIndex( |
| 2456 | const std::shared_ptr<DataType>& type, const std::vector<int64_t>& shape, |
no test coverage detected