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

Function ValidateSparseCSFIndexMetadata

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

Source from the content-addressed store, hash-verified

2310namespace {
2311
2312Status ValidateSparseCSFIndexMetadata(const flatbuf::SparseTensorIndexCSF* sparse_index,
2313 int64_t ndim) {
2314 if (sparse_index == nullptr) {
2315 return Status::Invalid("Missing CSF sparse index metadata");
2316 }
2317 auto* indptr_buffers = sparse_index->indptrBuffers();
2318 auto* indices_buffers = sparse_index->indicesBuffers();
2319 auto* axis_order = sparse_index->axisOrder();
2320 if (ndim < 2 || indptr_buffers == nullptr || indices_buffers == nullptr ||
2321 axis_order == nullptr || static_cast<int64_t>(indptr_buffers->size()) != ndim - 1 ||
2322 static_cast<int64_t>(indices_buffers->size()) != ndim ||
2323 static_cast<int64_t>(axis_order->size()) != ndim) {
2324 return Status::Invalid(
2325 "Inconsistent CSF sparse index: a CSF tensor must have at least 2 dimensions "
2326 "with indptr, indices and axis_order counts of ndim - 1, ndim and ndim");
2327 }
2328 return Status::OK();
2329}
2330
2331Result<std::shared_ptr<SparseIndex>> ReadSparseCOOIndex(
2332 const flatbuf::SparseTensor* sparse_tensor, const std::vector<int64_t>& shape,

Callers 2

ReadSparseCSFIndexFunction · 0.85
ReadSparseTensorPayloadFunction · 0.85

Calls 3

InvalidFunction · 0.50
OKFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected