MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / buildDenseIndptr

Function buildDenseIndptr

src/main/query_result/arrow_query_result.cpp:83–101  ·  view source on GitHub ↗

Build a dense global indptr of size numSourceRows+1 from sparse (srcRows, counts) runs. indptr[src+1] is set to counts[i] for the touched src = srcRows[i], then prefix-summed so indptr[src] gives the offset of src's edges in the (source-sorted) indices vector. Source rows absent from srcRows keep their slot at 0, i.e. no edges. Returns an empty vector on validation failure (bad src/count, or the d

Source from the content-addressed store, hash-verified

81// disjointness invariant is violated — a source row appearing more than
82// once would silently corrupt the merged CSR).
83static std::vector<int64_t> buildDenseIndptr(int64_t numSourceRows,
84 const std::vector<int64_t>& srcRows, const std::vector<int64_t>& counts) {
85 std::vector<int64_t> indptr(static_cast<size_t>(numSourceRows) + 1, 0);
86 for (auto i = 0u; i < srcRows.size(); ++i) {
87 const auto src = srcRows[i];
88 const auto count = counts[i];
89 if (src < 0 || src >= numSourceRows || count < 0) {
90 return {};
91 }
92 if (indptr[static_cast<size_t>(src) + 1] != 0) {
93 return {};
94 }
95 indptr[static_cast<size_t>(src) + 1] = count;
96 }
97 for (size_t i = 0; i + 1 < indptr.size(); ++i) {
98 indptr[i + 1] += indptr[i];
99 }
100 return indptr;
101}
102
103// K-way merge of per-batch sparse CSR metadata chunks (in batch_index
104// order) into a single flat CSRMetadata with a dense global indptr.

Callers 1

kwayMergeCSRChunksFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected