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

Method AppendSelected

cpp/src/arrow/compute/light_array_internal.cc:481–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

479}
480
481Status ExecBatchBuilder::AppendSelected(const std::shared_ptr<ArrayData>& source,
482 ResizableArrayData* target,
483 int num_rows_to_append, const uint16_t* row_ids,
484 MemoryPool* pool) {
485 int num_rows_before = target->num_rows();
486 ARROW_DCHECK(num_rows_before >= 0);
487 int num_rows_after = num_rows_before + num_rows_to_append;
488 if (target->num_rows() == 0) {
489 RETURN_NOT_OK(target->Init(source->type, pool, kLogNumRows));
490 }
491 RETURN_NOT_OK(target->ResizeFixedLengthBuffers(num_rows_after));
492
493 // Since target->Init is called before, we can assume that the ColumnMetadata
494 // would never fail to be created
495 KeyColumnMetadata column_metadata =
496 ColumnMetadataFromDataType(source->type).ValueOrDie();
497
498 if (column_metadata.is_fixed_length) {
499 // Fixed length column
500 //
501 uint32_t fixed_length = column_metadata.fixed_length;
502 switch (fixed_length) {
503 case 0:
504 CollectBits(source->buffers[1]->data(), source->offset, target->mutable_data(1),
505 num_rows_before, num_rows_to_append, row_ids);
506 break;
507 case 1:
508 Visit(source, num_rows_to_append, row_ids,
509 [&](int i, const uint8_t* ptr, int32_t num_bytes) {
510 target->mutable_data(1)[num_rows_before + i] = *ptr;
511 });
512 break;
513 case 2:
514 Visit(
515 source, num_rows_to_append, row_ids,
516 [&](int i, const uint8_t* ptr, int32_t num_bytes) {
517 reinterpret_cast<uint16_t*>(target->mutable_data(1))[num_rows_before + i] =
518 *reinterpret_cast<const uint16_t*>(ptr);
519 });
520 break;
521 case 4:
522 Visit(
523 source, num_rows_to_append, row_ids,
524 [&](int i, const uint8_t* ptr, int32_t num_bytes) {
525 reinterpret_cast<uint32_t*>(target->mutable_data(1))[num_rows_before + i] =
526 *reinterpret_cast<const uint32_t*>(ptr);
527 });
528 break;
529 case 8:
530 Visit(
531 source, num_rows_to_append, row_ids,
532 [&](int i, const uint8_t* ptr, int32_t num_bytes) {
533 reinterpret_cast<uint64_t*>(target->mutable_data(1))[num_rows_before + i] =
534 *reinterpret_cast<const uint64_t*>(ptr);
535 });
536 break;
537 default: {
538 int num_rows_to_process =

Callers 4

AppendProbeOnlyMethod · 0.80
AppendMethod · 0.80
TESTFunction · 0.80

Calls 15

CeilDivFunction · 0.85
SafeLoadFunction · 0.85
AddWithOverflowFunction · 0.85
BytesForBitsFunction · 0.85
num_rows_maxFunction · 0.85
CapacityErrorFunction · 0.85
ValueOrDieMethod · 0.80
resizeMethod · 0.80
is_arrayMethod · 0.80
VisitFunction · 0.70

Tested by 1

TESTFunction · 0.64