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

Method copy

bolt/vector/FlatVector.cpp:332–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330
331template <>
332void FlatVector<StringView>::copy(
333 const BaseVector* source,
334 const SelectivityVector& rows,
335 const vector_size_t* toSourceRow,
336 bool canCopyAll) {
337 if (!rows.hasSelections()) {
338 return;
339 }
340
341 // Source can be of Unknown type, in that case it should have null values.
342 if (source->typeKind() == TypeKind::UNKNOWN) {
343 if (source->isConstantEncoding()) {
344 DCHECK(source->isNullAt(0));
345 rows.applyToSelected([&](vector_size_t row) { setNull(row, true); });
346 } else {
347 rows.applyToSelected([&](vector_size_t row) {
348 auto sourceRow = toSourceRow ? toSourceRow[row] : row;
349 DCHECK(source->isNullAt(sourceRow));
350 setNull(row, true);
351 });
352 }
353 return;
354 }
355
356 auto leaf = source->wrappedVector()->asUnchecked<SimpleVector<StringView>>();
357
358 if (pool_ == leaf->pool()) {
359 // We copy referencing the storage of 'source'.
360 copyValuesAndNulls<false>(source, rows, toSourceRow);
361 acquireSharedStringBuffers(source);
362 } else {
363 DecodedVector decoded(*source);
364 uint64_t* rawNulls = const_cast<uint64_t*>(BaseVector::rawNulls_);
365 if (decoded.mayHaveNulls()) {
366 rawNulls = BaseVector::mutableRawNulls();
367 }
368
369 size_t totalBytes = 0;
370 uint64_t maxLen = 0;
371 rows.applyToSelected([&](vector_size_t row) {
372 const auto sourceRow = toSourceRow ? toSourceRow[row] : row;
373 if (decoded.isNullAt(sourceRow)) {
374 bits::setNull(rawNulls, row);
375 } else {
376 if (rawNulls) {
377 bits::clearNull(rawNulls, row);
378 }
379 auto v = decoded.valueAt<StringView>(sourceRow);
380 maxLen = std::max(maxLen, static_cast<uint64_t>(v.size()));
381 if (v.isInline()) {
382 rawValues_[row] = v;
383 } else {
384 totalBytes += v.size();
385 }
386 }
387 });
388 if (rows.countSelected() == BaseVector::length_) {
389 setStringViewStats(StringViewStats{totalBytes, maxLen});

Callers

nothing calls this directly

Calls 15

mutableRawNullsFunction · 0.85
clearNullFunction · 0.85
memcpyFunction · 0.85
hasSelectionsMethod · 0.80
applyToSelectedMethod · 0.80
isInlineMethod · 0.80
countSelectedMethod · 0.80
isAsciiMethod · 0.80
isAllAsciiMethod · 0.80
deselectMethod · 0.80
setNullFunction · 0.70

Tested by

no test coverage detected