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

Method ByteSwapBuffer

cpp/src/arrow/array/util.cc:114–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112
113 template <typename T>
114 Result<std::shared_ptr<Buffer>> ByteSwapBuffer(
115 const std::shared_ptr<Buffer>& in_buffer) {
116 if (sizeof(T) == 1) {
117 // if data size is 1, element is not swapped. We can use the original buffer
118 return in_buffer;
119 }
120 auto in_data = reinterpret_cast<const T*>(in_buffer->data());
121 ARROW_ASSIGN_OR_RAISE(auto out_buffer, AllocateBuffer(in_buffer->size(), pool_));
122 auto out_data = reinterpret_cast<T*>(out_buffer->mutable_data());
123 // NOTE: data_->length not trusted (see warning above)
124 int64_t length = in_buffer->size() / sizeof(T);
125 for (int64_t i = 0; i < length; i++) {
126 out_data[i] = bit_util::ByteSwap(in_data[i]);
127 }
128 // R build with openSUSE155 requires an explicit shared_ptr construction
129 return std::shared_ptr<Buffer>(std::move(out_buffer));
130 }
131
132 template <typename VALUE_TYPE>
133 Status SwapOffsets(int index) {

Callers

nothing calls this directly

Calls 4

ByteSwapFunction · 0.85
dataMethod · 0.45
mutable_dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected