MCPcopy Create free account
hub / github.com/bytedance/bolt / exportValidityBitmap

Function exportValidityBitmap

bolt/vector/arrow/Bridge.cpp:787–830  ·  view source on GitHub ↗

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).

Source from the content-addressed store, hash-verified

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).
787void 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
832bool isFlatScalarZeroCopy(const TypePtr& type) {
833 // - Short decimals need to be converted to 128 bit values as they are

Callers 4

exportRowsImplFunction · 0.85
flattenAndExportFunction · 0.85
exportFlattenedVectorFunction · 0.85
exportToArrowImplFunction · 0.85

Calls 10

nbytesFunction · 0.85
fillBitsFunction · 0.85
gatherFromBufferFunction · 0.85
setBufferMethod · 0.80
changedMethod · 0.80
countNullsFunction · 0.50
typeKindMethod · 0.45
countMethod · 0.45
encodingMethod · 0.45
nullsMethod · 0.45

Tested by

no test coverage detected