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

Method GetRowOffsetsSelected

cpp/src/arrow/compute/row/encode_internal.cc:668–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

666}
667
668Status EncoderOffsets::GetRowOffsetsSelected(RowTableImpl* rows,
669 const std::vector<KeyColumnArray>& cols,
670 uint32_t num_selected,
671 const uint16_t* selection) {
672 if (rows->metadata().is_fixed_length) {
673 return Status::OK();
674 }
675
676 RowTableImpl::offset_type* row_offsets = rows->mutable_offsets();
677 for (uint32_t i = 0; i < num_selected; ++i) {
678 row_offsets[i] = rows->metadata().fixed_length;
679 }
680
681 for (size_t icol = 0; icol < cols.size(); ++icol) {
682 bool is_fixed_length = (cols[icol].metadata().is_fixed_length);
683 if (!is_fixed_length) {
684 const uint32_t* col_offsets = cols[icol].offsets();
685 for (uint32_t i = 0; i < num_selected; ++i) {
686 uint32_t irow = selection[i];
687 uint32_t length = col_offsets[irow + 1] - col_offsets[irow];
688 row_offsets[i] += RowTableMetadata::padding_for_alignment_row(
689 row_offsets[i], rows->metadata().string_alignment);
690 row_offsets[i] += length;
691 }
692 const uint8_t* non_null_bits = cols[icol].data(0);
693 if (non_null_bits) {
694 const uint32_t* col_offsets = cols[icol].offsets();
695 for (uint32_t i = 0; i < num_selected; ++i) {
696 uint32_t irow = selection[i];
697 bool is_null =
698 !bit_util::GetBit(non_null_bits, irow + cols[icol].bit_offset(0));
699 if (is_null) {
700 uint32_t length = col_offsets[irow + 1] - col_offsets[irow];
701 row_offsets[i] -= length;
702 }
703 }
704 }
705 }
706 }
707
708 int64_t sum = 0;
709 int row_alignment = rows->metadata().row_alignment;
710 for (uint32_t i = 0; i < num_selected; ++i) {
711 RowTableImpl::offset_type length = row_offsets[i];
712 length += RowTableMetadata::padding_for_alignment_row(length, row_alignment);
713 row_offsets[i] = sum;
714 sum += length;
715 }
716 row_offsets[num_selected] = sum;
717
718 return Status::OK();
719}
720
721template <bool has_nulls, bool is_first_varbinary>
722void EncoderOffsets::EncodeSelectedImp(uint32_t ivarbinary, RowTableImpl* rows,

Callers

nothing calls this directly

Calls 7

OKFunction · 0.50
GetBitFunction · 0.50
metadataMethod · 0.45
sizeMethod · 0.45
offsetsMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected