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

Function ComputeSparseCSXIndptrLength

cpp/src/arrow/sparse_tensor.cc:301–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299namespace internal {
300
301Result<int64_t> ComputeSparseCSXIndptrLength(SparseMatrixCompressedAxis compressed_axis,
302 const std::vector<int64_t>& shape) {
303 if (shape.size() != 2) {
304 return Status::Invalid("Invalid shape length for a sparse matrix");
305 }
306 const int64_t compressed_axis_size =
307 compressed_axis == SparseMatrixCompressedAxis::ROW ? shape[0] : shape[1];
308 const auto indptr_length =
309 AddWithOverflow<int64_t>({compressed_axis_size, static_cast<int64_t>(1)});
310 if (!indptr_length.has_value()) {
311 return Status::Invalid("shape is inconsistent to the size of indptr buffer");
312 }
313 return indptr_length.value();
314}
315
316Status ValidateSparseCSXIndex(const std::shared_ptr<DataType>& indptr_type,
317 const std::shared_ptr<DataType>& indices_type,

Callers

nothing calls this directly

Calls 3

InvalidFunction · 0.70
sizeMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected