This functions does two things: (a) sets the value of null_count, and (b) the validity buffer (if there is at least one null row).
| 785 | // This functions does two things: (a) sets the value of null_count, and (b) |
| 786 | // the validity buffer (if there is at least one null row). |
| 787 | void exportValidityBitmap( |
| 788 | const BaseVector& vec, |
| 789 | const Selection& rows, |
| 790 | const ArrowOptions& options, |
| 791 | ArrowArray& out, |
| 792 | memory::MemoryPool* pool, |
| 793 | BoltToArrowBridgeHolder& holder) { |
| 794 | if (options.exportToArrowIPC && vec.typeKind() == TypeKind::UNKNOWN) { |
| 795 | out.null_count = rows.count(); |
| 796 | if (vec.encoding() == VectorEncoding::Simple::DICTIONARY) { |
| 797 | auto nulls = |
| 798 | AlignedBuffer::allocate<char>(bits::nbytes(out.length), pool); |
| 799 | auto raw = nulls->asMutable<uint64_t>(); |
| 800 | bits::fillBits(raw, 0, out.length, bits::kNull); |
| 801 | holder.setBuffer(0, nulls); |
| 802 | } |
| 803 | return; |
| 804 | } |
| 805 | |
| 806 | if (!vec.nulls()) { |
| 807 | out.null_count = 0; |
| 808 | return; |
| 809 | } |
| 810 | if (vec.encoding() == VectorEncoding::Simple::CONSTANT) { |
| 811 | // If Arrow REE is used, do not need to set nulls buffer; |
| 812 | // If flattenConstant is true, nulls will be set after flattening. |
| 813 | out.null_count = rows.count(); |
| 814 | return; |
| 815 | } |
| 816 | |
| 817 | auto nulls = vec.nulls(); |
| 818 | |
| 819 | // If we're only exporting a subset, create a new validity buffer. |
| 820 | if (rows.changed()) { |
| 821 | nulls = AlignedBuffer::allocate<bool>(out.length, pool); |
| 822 | gatherFromBuffer(*BOOLEAN(), *vec.nulls(), rows, options, *nulls); |
| 823 | } |
| 824 | |
| 825 | // Set null counts. |
| 826 | out.null_count = BaseVector::countNulls(nulls, rows.count()); |
| 827 | if (out.null_count > 0) { |
| 828 | holder.setBuffer(0, nulls); |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | bool isFlatScalarZeroCopy(const TypePtr& type) { |
| 833 | // - Short decimals need to be converted to 128 bit values as they are |
no test coverage detected