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

Function WritePaddedWithOffset

cpp/src/arrow/ipc/feather.cc:78–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78Status WritePaddedWithOffset(io::OutputStream* stream, const uint8_t* data,
79 int64_t bit_offset, const int64_t length,
80 int64_t* bytes_written) {
81 data = data + bit_offset / 8;
82 uint8_t bit_shift = static_cast<uint8_t>(bit_offset % 8);
83 if (bit_offset == 0) {
84 RETURN_NOT_OK(stream->Write(data, length));
85 } else {
86 constexpr int64_t buffersize = 256;
87 uint8_t buffer[buffersize];
88 const uint8_t lshift = static_cast<uint8_t>(8 - bit_shift);
89 const uint8_t* buffer_end = buffer + buffersize;
90 uint8_t* buffer_it = buffer;
91
92 for (const uint8_t* end = data + length; data != end;) {
93 uint8_t r = static_cast<uint8_t>(*data++ >> bit_shift);
94 uint8_t l = static_cast<uint8_t>(*data << lshift);
95 uint8_t value = l | r;
96 *buffer_it++ = value;
97 if (buffer_it == buffer_end) {
98 RETURN_NOT_OK(stream->Write(buffer, buffersize));
99 buffer_it = buffer;
100 }
101 }
102 if (buffer_it != buffer) {
103 RETURN_NOT_OK(stream->Write(buffer, buffer_it - buffer));
104 }
105 }
106
107 int64_t remainder = PaddedLength(length) - length;
108 if (remainder != 0) {
109 RETURN_NOT_OK(stream->Write(kPaddingBytes, remainder));
110 }
111 *bytes_written = length + remainder;
112 return Status::OK();
113}
114
115Status WritePadded(io::OutputStream* stream, const uint8_t* data, int64_t length,
116 int64_t* bytes_written) {

Callers 2

WritePaddedFunction · 0.85
WriteBufferMethod · 0.85

Calls 3

PaddedLengthFunction · 0.70
OKFunction · 0.50
WriteMethod · 0.45

Tested by

no test coverage detected