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

Function ValidateSparseCSFIndexMetadata

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

Source from the content-addressed store, hash-verified

2293namespace {
2294
2295Status ValidateSparseCSFIndexMetadata(const flatbuf::SparseTensorIndexCSF* sparse_index,
2296 int64_t ndim) {
2297 if (sparse_index == nullptr) {
2298 return Status::Invalid("Missing CSF sparse index metadata");
2299 }
2300 auto* indptr_buffers = sparse_index->indptrBuffers();
2301 auto* indices_buffers = sparse_index->indicesBuffers();
2302 auto* axis_order = sparse_index->axisOrder();
2303 if (ndim < 2 || indptr_buffers == nullptr || indices_buffers == nullptr ||
2304 axis_order == nullptr || static_cast<int64_t>(indptr_buffers->size()) != ndim - 1 ||
2305 static_cast<int64_t>(indices_buffers->size()) != ndim ||
2306 static_cast<int64_t>(axis_order->size()) != ndim) {
2307 return Status::Invalid(
2308 "Inconsistent CSF sparse index: a CSF tensor must have at least 2 dimensions "
2309 "with indptr, indices and axis_order counts of ndim - 1, ndim and ndim");
2310 }
2311 return Status::OK();
2312}
2313
2314Result<std::shared_ptr<SparseIndex>> ReadSparseCOOIndex(
2315 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