MCPcopy Create free account
hub / github.com/bytedance/bolt / copyRangesImpl

Method copyRangesImpl

bolt/vector/ComplexVector.cpp:519–641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519void ArrayVectorBase::copyRangesImpl(
520 const BaseVector* source,
521 const folly::Range<const BaseVector::CopyRange*>& ranges,
522 VectorPtr* targetValues,
523 VectorPtr* targetKeys) {
524 if (isAllNullVector(*source)) {
525 BaseVector::setNulls(mutableRawNulls(), ranges, true);
526 return;
527 }
528
529 const BaseVector* sourceValues;
530 const BaseVector* sourceKeys = nullptr;
531
532 auto leafSource = source->wrappedVector();
533 BOLT_CHECK_EQ(leafSource->encoding(), encoding());
534
535 if (typeKind_ == TypeKind::ARRAY) {
536 sourceValues = leafSource->as<ArrayVector>()->elements().get();
537 } else {
538 sourceValues = leafSource->as<MapVector>()->mapValues().get();
539 sourceKeys = leafSource->as<MapVector>()->mapKeys().get();
540 }
541
542 if (targetKeys) {
543 BaseVector::ensureWritable(
544 SelectivityVector::empty(),
545 targetKeys->get()->type(),
546 pool(),
547 *targetKeys);
548 } else {
549 BaseVector::ensureWritable(
550 SelectivityVector::empty(),
551 targetValues->get()->type(),
552 pool(),
553 *targetValues);
554 }
555
556 auto sourceArray = leafSource->asUnchecked<ArrayVectorBase>();
557 auto setNotNulls = mayHaveNulls() || source->mayHaveNulls();
558 auto* mutableOffsets = offsets_->asMutable<vector_size_t>();
559 auto* mutableSizes = sizes_->asMutable<vector_size_t>();
560 vector_size_t childSize = targetValues->get()->size();
561 if (ranges.size() == 1 && ranges.back().count == 1) {
562 auto& range = ranges.back();
563 if (range.count == 0) {
564 return;
565 }
566 BOLT_DCHECK(BaseVector::length_ >= range.targetIndex + range.count);
567 // Fast path if we're just copying a single array.
568 if (source->isNullAt(range.sourceIndex)) {
569 setNull(range.targetIndex, true);
570 } else {
571 if (setNotNulls) {
572 setNull(range.targetIndex, false);
573 }
574
575 vector_size_t wrappedIndex = source->wrappedIndex(range.sourceIndex);
576 vector_size_t copySize = sourceArray->sizeAt(wrappedIndex);

Callers

nothing calls this directly

Calls 15

isAllNullVectorFunction · 0.85
mutableRawNullsFunction · 0.85
ensureWritableFunction · 0.85
mayHaveNullsFunction · 0.85
applyToEachRangeFunction · 0.85
applyToEachRowFunction · 0.85
backMethod · 0.80
sizeAtMethod · 0.80
offsetAtMethod · 0.80
encodingFunction · 0.70
poolFunction · 0.70
setNullFunction · 0.70

Tested by

no test coverage detected