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

Method copyStringToLocal

bolt/exec/VectorHasher.cpp:613–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611}
612
613void VectorHasher::copyStringToLocal(const UniqueValue* unique) {
614 auto size = unique->size();
615 if (size <= sizeof(int64_t)) {
616 return;
617 }
618 if (distinctStringsBytes_ > kMaxDistinctStringsBytes) {
619 setDistinctOverflow();
620 return;
621 }
622 if (uniqueValuesStorage_.empty()) {
623 uniqueValuesStorage_.emplace_back();
624 uniqueValuesStorage_.back().reserve(std::max(kStringBufferUnitSize, size));
625 distinctStringsBytes_ += uniqueValuesStorage_.back().capacity();
626 }
627 auto str = &uniqueValuesStorage_.back();
628 if (str->size() + size > str->capacity()) {
629 uniqueValuesStorage_.emplace_back();
630 uniqueValuesStorage_.back().reserve(std::max(kStringBufferUnitSize, size));
631 distinctStringsBytes_ += uniqueValuesStorage_.back().capacity();
632 str = &uniqueValuesStorage_.back();
633 }
634 auto start = str->size();
635 str->resize(start + size);
636 memcpy(str->data() + start, reinterpret_cast<char*>(unique->data()), size);
637 const_cast<UniqueValue*>(unique)->setData(
638 reinterpret_cast<int64_t>(str->data() + start));
639}
640
641void VectorHasher::setDistinctOverflow() {
642 distinctOverflow_ = true;

Callers

nothing calls this directly

Calls 10

memcpyFunction · 0.85
backMethod · 0.80
maxFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45
reserveMethod · 0.45
capacityMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
setDataMethod · 0.45

Tested by

no test coverage detected