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

Method EncodeAndAppend

cpp/src/arrow/compute/row/row_encoder_internal.cc:324–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324Status RowEncoder::EncodeAndAppend(const ExecSpan& batch) {
325 if (offsets_.empty()) {
326 offsets_.resize(1);
327 offsets_[0] = 0;
328 }
329 size_t length_before = offsets_.size() - 1;
330 offsets_.resize(length_before + batch.length + 1);
331 for (int64_t i = 0; i < batch.length; ++i) {
332 offsets_[length_before + 1 + i] = 0;
333 }
334
335 for (int i = 0; i < batch.num_values(); ++i) {
336 encoders_[i]->AddLength(batch[i], batch.length, offsets_.data() + length_before + 1);
337 }
338
339 int32_t total_length = offsets_[length_before];
340 for (int64_t i = 0; i < batch.length; ++i) {
341 total_length += offsets_[length_before + 1 + i];
342 offsets_[length_before + 1 + i] = total_length;
343 }
344
345 bytes_.resize(total_length);
346 std::vector<uint8_t*> buf_ptrs(batch.length);
347 for (int64_t i = 0; i < batch.length; ++i) {
348 buf_ptrs[i] = bytes_.data() + offsets_[length_before + i];
349 }
350
351 for (int i = 0; i < batch.num_values(); ++i) {
352 RETURN_NOT_OK(encoders_[i]->Encode(batch[i], batch.length, buf_ptrs.data()));
353 }
354
355 return Status::OK();
356}
357
358Result<ExecBatch> RowEncoder::Decode(int64_t num_rows, const int32_t* row_ids) {
359 ExecBatch out({}, num_rows);

Callers 6

EncodeBatchMethod · 0.80
InitMethod · 0.80
RemapInputValuesMethod · 0.80
RemapInputMethod · 0.80
EncodeBatchMethod · 0.80
GenRandomUniqueRecordsFunction · 0.80

Calls 8

resizeMethod · 0.80
OKFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
num_valuesMethod · 0.45
AddLengthMethod · 0.45
dataMethod · 0.45
EncodeMethod · 0.45

Tested by 1

GenRandomUniqueRecordsFunction · 0.64