MCPcopy Create free account
hub / github.com/apache/arrow / ReadSparseCSFIndex

Function ReadSparseCSFIndex

cpp/src/arrow/ipc/reader.cc:2370–2397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2368}
2369
2370Result<std::shared_ptr<SparseIndex>> ReadSparseCSFIndex(
2371 const flatbuf::SparseTensor* sparse_tensor, const std::vector<int64_t>& shape,
2372 io::RandomAccessFile* file) {
2373 auto* sparse_index = sparse_tensor->sparseIndex_as_SparseTensorIndexCSF();
2374 const auto ndim = static_cast<int64_t>(shape.size());
2375 auto* indptr_buffers = sparse_index->indptrBuffers();
2376 auto* indices_buffers = sparse_index->indicesBuffers();
2377 std::vector<std::shared_ptr<Buffer>> indptr_data(ndim - 1);
2378 std::vector<std::shared_ptr<Buffer>> indices_data(ndim);
2379
2380 std::shared_ptr<DataType> indptr_type, indices_type;
2381 std::vector<int64_t> axis_order, indices_size;
2382
2383 RETURN_NOT_OK(internal::GetSparseCSFIndexMetadata(
2384 sparse_index, &axis_order, &indices_size, &indptr_type, &indices_type));
2385 for (int i = 0; i < static_cast<int>(indptr_buffers->size()); ++i) {
2386 ARROW_ASSIGN_OR_RAISE(indptr_data[i], file->ReadAt(indptr_buffers->Get(i)->offset(),
2387 indptr_buffers->Get(i)->length()));
2388 }
2389 for (int i = 0; i < static_cast<int>(indices_buffers->size()); ++i) {
2390 ARROW_ASSIGN_OR_RAISE(indices_data[i],
2391 file->ReadAt(indices_buffers->Get(i)->offset(),
2392 indices_buffers->Get(i)->length()));
2393 }
2394
2395 return SparseCSFIndex::Make(indptr_type, indices_type, indices_size, axis_order,
2396 indptr_data, indices_data);
2397}
2398
2399Result<std::shared_ptr<SparseTensor>> MakeSparseTensorWithSparseCOOIndex(
2400 const std::shared_ptr<DataType>& type, const std::vector<int64_t>& shape,

Callers 1

ReadSparseTensorFunction · 0.85

Calls 8

ARROW_ASSIGN_OR_RAISEFunction · 0.70
MakeFunction · 0.50
sizeMethod · 0.45
ReadAtMethod · 0.45
offsetMethod · 0.45
GetMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected