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

Method CopyFixedWidthValues

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

Source from the content-addressed store, hash-verified

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