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

Function CopyEndChars

cpp/src/arrow/csv/writer.cc:70–79  ·  view source on GitHub ↗

This function is to improve performance. It copies CSV delimiter and eol without calling `memcpy`. Each CSV field is followed by a delimiter or eol, which is often only one or two chars. If copying both the field and delimiter with `memcpy`, CPU may suffer from high branch misprediction as we are tripping `memcpy` with interleaved (normal/tiny/normal/tiny/...) buffer sizes, which are handled separ

Source from the content-addressed store, hash-verified

68// separately inside `memcpy`. This function goes fast path if the buffer
69// size is one or two chars to leave `memcpy` only for copying CSV fields.
70void CopyEndChars(char* dest, const char* src, size_t size) {
71 if (size == 1) {
72 // for fixed size memcpy, compiler will generate direct load/store opcode
73 memcpy(dest, src, 1);
74 } else if (size == 2) {
75 memcpy(dest, src, 2);
76 } else {
77 memcpy(dest, src, size);
78 }
79}
80
81struct SliceIteratorFunctor {
82 Result<std::shared_ptr<RecordBatch>> Next() {

Callers 2

PopulateRowsMethod · 0.85
PopulateRowsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected