| 1556 | } |
| 1557 | |
| 1558 | VectorPtr VectorLoaderWrap::makeEncodingPreservedCopy( |
| 1559 | SelectivityVector& rows, |
| 1560 | vector_size_t vectorSize) { |
| 1561 | DecodedVector decoded; |
| 1562 | decoded.decode(*vector_, rows, false); |
| 1563 | |
| 1564 | if (decoded.isConstantMapping() || decoded.isIdentityMapping()) { |
| 1565 | VectorPtr result; |
| 1566 | BaseVector::ensureWritable(rows, vector_->type(), vector_->pool(), result); |
| 1567 | result->resize(vectorSize); |
| 1568 | result->copy(vector_.get(), rows, nullptr, false); |
| 1569 | return result; |
| 1570 | } |
| 1571 | |
| 1572 | SelectivityVector baseRows; |
| 1573 | auto baseVector = decoded.base(); |
| 1574 | |
| 1575 | baseRows.resize(baseVector->size(), false); |
| 1576 | rows.applyToSelected([&](auto row) { |
| 1577 | if (!decoded.isNullAt(row)) { |
| 1578 | baseRows.setValid(decoded.index(row), true); |
| 1579 | } |
| 1580 | }); |
| 1581 | baseRows.updateBounds(); |
| 1582 | |
| 1583 | VectorPtr baseResult; |
| 1584 | BaseVector::ensureWritable( |
| 1585 | baseRows, baseVector->type(), vector_->pool(), baseResult); |
| 1586 | baseResult->copy(baseVector, baseRows, nullptr, false); |
| 1587 | |
| 1588 | BufferPtr indices = allocateIndices(vectorSize, vector_->pool()); |
| 1589 | auto rawIndices = indices->asMutable<vector_size_t>(); |
| 1590 | auto decodedIndices = decoded.indices(); |
| 1591 | rows.applyToSelected( |
| 1592 | [&](auto row) { rawIndices[row] = decodedIndices[row]; }); |
| 1593 | |
| 1594 | BufferPtr nulls = nullptr; |
| 1595 | if (decoded.nulls(&rows) || vectorSize > rows.end()) { |
| 1596 | // We fill [rows.end(), vectorSize) with nulls then copy nulls for selected |
| 1597 | // baseRows. |
| 1598 | nulls = allocateNulls(vectorSize, vector_->pool(), bits::kNull); |
| 1599 | if (baseRows.hasSelections()) { |
| 1600 | if (decoded.nulls(&rows)) { |
| 1601 | std::memcpy( |
| 1602 | nulls->asMutable<uint64_t>(), |
| 1603 | decoded.nulls(&rows), |
| 1604 | bits::nbytes(rows.end())); |
| 1605 | } else { |
| 1606 | bits::fillBits( |
| 1607 | nulls->asMutable<uint64_t>(), 0, rows.end(), bits::kNotNull); |
| 1608 | } |
| 1609 | } |
| 1610 | } |
| 1611 | |
| 1612 | return BaseVector::wrapInDictionary( |
| 1613 | std::move(nulls), std::move(indices), vectorSize, baseResult); |
| 1614 | } |
| 1615 |
nothing calls this directly
no test coverage detected