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

Method Decode

cpp/src/arrow/compute/row/row_encoder_internal.h:233–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231 using typename Base::Offset;
232
233 Result<std::shared_ptr<ArrayData>> Decode(uint8_t** encoded_bytes, int32_t length,
234 MemoryPool* pool) override {
235 std::shared_ptr<Buffer> null_buf;
236 int32_t null_count;
237 ARROW_RETURN_NOT_OK(
238 this->DecodeNulls(pool, length, encoded_bytes, &null_buf, &null_count));
239
240 Offset length_sum = 0;
241 for (int32_t i = 0; i < length; ++i) {
242 length_sum += util::SafeLoadAs<Offset>(encoded_bytes[i]);
243 }
244
245 ARROW_ASSIGN_OR_RAISE(auto offset_buf,
246 AllocateBuffer(sizeof(Offset) * (1 + length), pool));
247 ARROW_ASSIGN_OR_RAISE(auto key_buf, AllocateBuffer(length_sum));
248
249 auto raw_offsets = reinterpret_cast<Offset*>(offset_buf->mutable_data());
250 auto raw_keys = key_buf->mutable_data();
251
252 Offset current_offset = 0;
253 for (int32_t i = 0; i < length; ++i) {
254 raw_offsets[i] = current_offset;
255
256 auto key_length = util::SafeLoadAs<Offset>(encoded_bytes[i]);
257 encoded_bytes[i] += sizeof(Offset);
258
259 memcpy(raw_keys + current_offset, encoded_bytes[i], key_length);
260 encoded_bytes[i] += key_length;
261
262 current_offset += key_length;
263 }
264 raw_offsets[length] = current_offset;
265
266 return ArrayData::Make(
267 type_, length, {std::move(null_buf), std::move(offset_buf), std::move(key_buf)},
268 null_count);
269 }
270};
271
272// Encodes BinaryView/StringView keys in the same row format as the plain

Callers

nothing calls this directly

Calls 3

MakeFunction · 0.50
DecodeNullsMethod · 0.45
mutable_dataMethod · 0.45

Tested by

no test coverage detected