| 222 | } |
| 223 | |
| 224 | bool ArrowRelTable::scanFlat(transaction::Transaction* transaction, TableScanState& scanState) { |
| 225 | auto& relScanState = scanState.cast<RelTableScanState>(); |
| 226 | if (relScanState.arrowScanCompleted || !relScanState.arrowSrcKeyVector || |
| 227 | !relScanState.arrowDstKeyVector) { |
| 228 | return false; |
| 229 | } |
| 230 | |
| 231 | scanState.resetOutVectors(); |
| 232 | auto outputCount = 0u; |
| 233 | constexpr uint64_t maxRowsPerCall = DEFAULT_VECTOR_CAPACITY; |
| 234 | auto activeBoundSelPos = INVALID_SEL; |
| 235 | auto activeBoundOffset = INVALID_OFFSET; |
| 236 | auto hasActiveBound = false; |
| 237 | const auto outputToArrowColumnIdx = getOutputToArrowColumnIdx(scanState.columnIDs); |
| 238 | |
| 239 | while (outputCount < maxRowsPerCall && relScanState.arrowCurrentBatchIdx < arrays.size()) { |
| 240 | const auto& batch = arrays[relScanState.arrowCurrentBatchIdx]; |
| 241 | auto batchLength = getArrowBatchLength(batch); |
| 242 | if (relScanState.arrowCurrentBatchOffset >= batchLength) { |
| 243 | relScanState.arrowCurrentBatchIdx++; |
| 244 | relScanState.arrowCurrentBatchOffset = 0; |
| 245 | continue; |
| 246 | } |
| 247 | |
| 248 | auto srcOffsetInBatch = relScanState.arrowCurrentBatchOffset; |
| 249 | auto numChildren = batch.n_children < 0 ? 0u : static_cast<uint64_t>(batch.n_children); |
| 250 | if (numChildren == 0 || !batch.children || !schema.children || |
| 251 | static_cast<uint64_t>(fromColumnIdx) >= numChildren || |
| 252 | static_cast<uint64_t>(toColumnIdx) >= numChildren || !batch.children[fromColumnIdx] || |
| 253 | !batch.children[toColumnIdx] || !schema.children[fromColumnIdx] || |
| 254 | !schema.children[toColumnIdx]) { |
| 255 | relScanState.arrowCurrentBatchOffset++; |
| 256 | continue; |
| 257 | } |
| 258 | |
| 259 | auto* srcChildArray = batch.children[fromColumnIdx]; |
| 260 | auto* srcChildSchema = schema.children[fromColumnIdx]; |
| 261 | auto* dstChildArray = batch.children[toColumnIdx]; |
| 262 | auto* dstChildSchema = schema.children[toColumnIdx]; |
| 263 | auto srcOffsetToRead = srcChildArray->offset + srcOffsetInBatch; |
| 264 | auto dstOffsetToRead = dstChildArray->offset + srcOffsetInBatch; |
| 265 | readSingleArrowValue(srcChildSchema, srcChildArray, *relScanState.arrowSrcKeyVector, |
| 266 | srcOffsetToRead, 0); |
| 267 | if (relScanState.arrowSrcKeyVector->isNull(0)) { |
| 268 | relScanState.arrowCurrentBatchOffset++; |
| 269 | continue; |
| 270 | } |
| 271 | readSingleArrowValue(dstChildSchema, dstChildArray, *relScanState.arrowDstKeyVector, |
| 272 | dstOffsetToRead, 0); |
| 273 | if (relScanState.arrowDstKeyVector->isNull(0)) { |
| 274 | relScanState.arrowCurrentBatchOffset++; |
| 275 | continue; |
| 276 | } |
| 277 | |
| 278 | offset_t srcNodeOffset = INVALID_OFFSET; |
| 279 | offset_t dstNodeOffset = INVALID_OFFSET; |
| 280 | if (!fromNodeTable->lookupPK(transaction, relScanState.arrowSrcKeyVector.get(), 0, |
| 281 | srcNodeOffset)) { |
nothing calls this directly
no test coverage detected