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

Method CopyFixedWidthValues

cpp/src/arrow/util/hashing.h:810–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

808 }
809
810 void CopyFixedWidthValues(int32_t start, int32_t width_size, int64_t out_size,
811 uint8_t* out_data) const {
812 // This method exists to cope with the fact that the BinaryMemoTable does
813 // not know the fixed width when inserting the null value. The data
814 // buffer hold a zero length string for the null value (if found).
815 //
816 // Thus, the method will properly inject an empty value of the proper width
817 // in the output buffer.
818 //
819 if (start >= size()) {
820 return;
821 }
822
823 int32_t null_index = GetNull();
824 if (null_index < start) {
825 // Nothing to skip, proceed as usual.
826 CopyValues(start, out_size, out_data);
827 return;
828 }
829
830 builder_offset_type left_offset = binary_builder_.offset(start);
831
832 // Ensure that the data length is exactly missing width_size bytes to fit
833 // in the expected output (n_values * width_size).
834#ifndef NDEBUG
835 int64_t data_length = values_size() - static_cast<size_t>(left_offset);
836 assert(data_length + width_size == out_size);
837 ARROW_UNUSED(data_length);
838#endif
839
840 auto in_data = binary_builder_.value_data() + left_offset;
841 // The null use 0-length in the data, slice the data in 2 and skip by
842 // width_size in out_data. [part_1][width_size][part_2]
843 auto null_data_offset = binary_builder_.offset(null_index);
844 auto left_size = null_data_offset - left_offset;
845 if (left_size > 0) {
846 memcpy(out_data, in_data + left_offset, left_size);
847 }
848 // Zero-initialize the null entry
849 memset(out_data + left_size, 0, width_size);
850
851 auto right_size = values_size() - static_cast<size_t>(null_data_offset);
852 if (right_size > 0) {
853 // skip the null fixed size value.
854 auto out_offset = left_size + width_size;
855 assert(out_data + out_offset + right_size == out_data + out_size);
856 memcpy(out_data + out_offset, in_data + null_data_offset, right_size);
857 }
858 }
859
860 // Visit the stored values in insertion order.
861 // The visitor function should have the signature `void(std::string_view)`

Callers 1

Calls 4

CopyValuesFunction · 0.85
sizeFunction · 0.50
offsetMethod · 0.45
value_dataMethod · 0.45

Tested by

no test coverage detected