| 149 | } // namespace |
| 150 | |
| 151 | static void updateCSRMetadata(const CSRTrackingInfo& info, FlatTuple& tuple, |
| 152 | ArrowResultCollectorLocalState& localState) { |
| 153 | if (!info.enabled() || !localState.csrMetadataValid) { |
| 154 | return; |
| 155 | } |
| 156 | const auto srcRowID = tuple.getValue(info.srcRowIDColIdx)->getValue<int64_t>(); |
| 157 | const auto dstRowID = tuple.getValue(info.dstRowIDColIdx)->getValue<int64_t>(); |
| 158 | if (!localState.csrMetadata.has_value()) { |
| 159 | main::ArrowQueryResult::CSRMetadata metadata; |
| 160 | metadata.hasEdgeIDs = info.hasRelRowID(); |
| 161 | metadata.numSourceRows = info.numSourceRows; |
| 162 | localState.csrMetadata = std::move(metadata); |
| 163 | } |
| 164 | auto& metadata = *localState.csrMetadata; |
| 165 | if (srcRowID < 0 || dstRowID < 0) { |
| 166 | localState.csrMetadataValid = false; |
| 167 | localState.csrMetadata.reset(); |
| 168 | return; |
| 169 | } |
| 170 | // See updateDirectCSRMetadata for the sparse run rationale. |
| 171 | if (localState.currentSourceRowID == -1) { |
| 172 | localState.currentSourceRowID = srcRowID; |
| 173 | localState.currentRowCount = 0; |
| 174 | } else if (srcRowID != localState.currentSourceRowID) { |
| 175 | if (srcRowID < localState.currentSourceRowID) { |
| 176 | localState.csrMetadataValid = false; |
| 177 | localState.csrMetadata.reset(); |
| 178 | return; |
| 179 | } |
| 180 | metadata.srcRows.push_back(localState.currentSourceRowID); |
| 181 | metadata.counts.push_back(localState.currentRowCount); |
| 182 | localState.currentSourceRowID = srcRowID; |
| 183 | localState.currentRowCount = 0; |
| 184 | } |
| 185 | metadata.indices.push_back(dstRowID); |
| 186 | if (info.hasRelRowID()) { |
| 187 | metadata.edgeIDs.push_back(tuple.getValue(info.relRowIDColIdx)->getValue<int64_t>()); |
| 188 | } |
| 189 | localState.currentRowCount++; |
| 190 | } |
| 191 | |
| 192 | bool ArrowResultCollectorLocalState::advance() { |
| 193 | for (int64_t i = static_cast<int64_t>(chunks.size()) - 1; i >= 0; --i) { |
no test coverage detected