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

Method EncodeAndAppend

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

Source from the content-addressed store, hash-verified

356}
357
358Status RowEncoder::EncodeAndAppend(const ExecSpan& batch) {
359 if (offsets_.empty()) {
360 offsets_.resize(1);
361 offsets_[0] = 0;
362 }
363 size_t length_before = offsets_.size() - 1;
364 offsets_.resize(length_before + batch.length + 1);
365 for (int64_t i = 0; i < batch.length; ++i) {
366 offsets_[length_before + 1 + i] = 0;
367 }
368
369 for (int i = 0; i < batch.num_values(); ++i) {
370 encoders_[i]->AddLength(batch[i], batch.length, offsets_.data() + length_before + 1);
371 }
372
373 int32_t total_length = offsets_[length_before];
374 for (int64_t i = 0; i < batch.length; ++i) {
375 total_length += offsets_[length_before + 1 + i];
376 offsets_[length_before + 1 + i] = total_length;
377 }
378
379 bytes_.resize(total_length);
380 std::vector<uint8_t*> buf_ptrs(batch.length);
381 for (int64_t i = 0; i < batch.length; ++i) {
382 buf_ptrs[i] = bytes_.data() + offsets_[length_before + i];
383 }
384
385 for (int i = 0; i < batch.num_values(); ++i) {
386 RETURN_NOT_OK(encoders_[i]->Encode(batch[i], batch.length, buf_ptrs.data()));
387 }
388
389 return Status::OK();
390}
391
392Result<ExecBatch> RowEncoder::Decode(int64_t num_rows, const int32_t* row_ids) {
393 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