| 301 | } |
| 302 | |
| 303 | static void scanArrowArrayDenseUnion(const ArrowSchema* schema, const ArrowArray* array, |
| 304 | ValueVector& outputVector, ArrowNullMaskTree* mask, uint64_t srcOffset, uint64_t dstOffset, |
| 305 | uint64_t count) { |
| 306 | auto types = ((const uint8_t*)array->buffers[0]) + srcOffset; |
| 307 | auto dstTypes = (uint16_t*)UnionVector::getTagVector(&outputVector)->getData(); |
| 308 | auto offsets = ((const int32_t*)array->buffers[1]) + srcOffset; |
| 309 | std::vector<int32_t> firstIncident(array->n_children, INT32_MAX); |
| 310 | |
| 311 | mask->copyToValueVector(&outputVector, dstOffset, count); |
| 312 | |
| 313 | rowIter(outputVector, count, [&](auto i) { |
| 314 | auto curType = types[i]; |
| 315 | auto curOffset = offsets[i]; |
| 316 | if (curOffset < firstIncident[curType]) { |
| 317 | firstIncident[curType] = curOffset; |
| 318 | } |
| 319 | if (!mask->isNull(i)) { |
| 320 | dstTypes[i] = curType; |
| 321 | auto childOffset = |
| 322 | mask->getChild(curType)->offsetBy(curOffset - firstIncident[curType]); |
| 323 | ArrowConverter::fromArrowArray(schema->children[curType], array->children[curType], |
| 324 | *UnionVector::getValVector(&outputVector, curType), &childOffset, |
| 325 | curOffset + array->children[curType]->offset, i + dstOffset, 1); |
| 326 | // may be inefficient, since we're only scanning a single value |
| 327 | } |
| 328 | }); |
| 329 | } |
| 330 | |
| 331 | static void scanArrowArraySparseUnion(const ArrowSchema* schema, const ArrowArray* array, |
| 332 | ValueVector& outputVector, ArrowNullMaskTree* mask, uint64_t srcOffset, uint64_t dstOffset, |
no test coverage detected