MCPcopy Create free account
hub / github.com/apache/arrow / AppendNulls

Method AppendNulls

cpp/src/arrow/compute/light_array_internal.cc:637–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635}
636
637Status ExecBatchBuilder::AppendNulls(const std::shared_ptr<DataType>& type,
638 ResizableArrayData& target, int num_rows_to_append,
639 MemoryPool* pool) {
640 int num_rows_before = target.num_rows();
641 int num_rows_after = num_rows_before + num_rows_to_append;
642 if (target.num_rows() == 0) {
643 RETURN_NOT_OK(target.Init(type, pool, kLogNumRows));
644 }
645 RETURN_NOT_OK(target.ResizeFixedLengthBuffers(num_rows_after));
646
647 ARROW_ASSIGN_OR_RAISE(KeyColumnMetadata column_metadata,
648 ColumnMetadataFromDataType(type));
649
650 // Process fixed length buffer
651 //
652 if (column_metadata.is_fixed_length) {
653 uint8_t* dst = target.mutable_data(1);
654 if (column_metadata.fixed_length == 0) {
655 dst[num_rows_before / 8] &= static_cast<uint8_t>((1 << (num_rows_before % 8)) - 1);
656 int64_t offset_begin = num_rows_before / 8 + 1;
657 int64_t offset_end = bit_util::BytesForBits(num_rows_after);
658 if (offset_end > offset_begin) {
659 memset(dst + offset_begin, 0, offset_end - offset_begin);
660 }
661 } else {
662 memset(dst + num_rows_before * static_cast<int64_t>(column_metadata.fixed_length),
663 0, static_cast<int64_t>(column_metadata.fixed_length) * num_rows_to_append);
664 }
665 } else {
666 uint32_t* dst = reinterpret_cast<uint32_t*>(target.mutable_data(1));
667 uint32_t sum = num_rows_before == 0 ? 0 : dst[num_rows_before];
668 for (int64_t i = num_rows_before; i <= num_rows_after; ++i) {
669 dst[i] = sum;
670 }
671 }
672
673 // Process nulls
674 //
675 uint8_t* dst = target.mutable_data(0);
676 dst[num_rows_before / 8] &= static_cast<uint8_t>((1 << (num_rows_before % 8)) - 1);
677 int64_t offset_begin = num_rows_before / 8 + 1;
678 int64_t offset_end = bit_util::BytesForBits(num_rows_after);
679 if (offset_end > offset_begin) {
680 memset(dst + offset_begin, 0, offset_end - offset_begin);
681 }
682
683 return Status::OK();
684}
685
686Status ExecBatchBuilder::AppendSelected(MemoryPool* pool, const ExecBatch& batch,
687 int num_rows_to_append, const uint16_t* row_ids,

Callers 10

InsertMethod · 0.45
TESTFunction · 0.45
AppendListSliceValuesMethod · 0.45
AccumulateMethod · 0.45
GenerateOutputMethod · 0.45
PairwiseExecFunction · 0.45
FinalizeMethod · 0.45

Calls 13

BytesForBitsFunction · 0.85
num_rows_maxFunction · 0.85
CapacityErrorFunction · 0.85
resizeMethod · 0.80
num_rowsFunction · 0.70
OKFunction · 0.50
AppendNullsFunction · 0.50
num_rowsMethod · 0.45
InitMethod · 0.45
mutable_dataMethod · 0.45
emptyMethod · 0.45

Tested by 2

TESTFunction · 0.36