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

Method wrap

bolt/expression/PeeledEncoding.cpp:259–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259VectorPtr PeeledEncoding::wrap(
260 const TypePtr& outputType,
261 bolt::memory::MemoryPool* pool,
262 VectorPtr peeledResult,
263 const SelectivityVector& rows) const {
264 BOLT_CHECK(wrapEncoding_ != VectorEncoding::Simple::FLAT);
265 VectorPtr wrappedResult;
266 if (wrapEncoding_ == VectorEncoding::Simple::DICTIONARY) {
267 if (!peeledResult) {
268 // If all rows are null, make a constant null vector of the right type.
269 wrappedResult =
270 BaseVector::createNullConstant(outputType, rows.size(), pool);
271 } else {
272 BufferPtr nulls;
273 if (!rows.isAllSelected()) {
274 // The new base vector may be shorter than the original base vector
275 // (e.g. if positions at the end of the original vector were not
276 // selected for evaluation). In this case some original indices
277 // corresponding to non-selected rows may point past the end of the base
278 // vector. Disable these by setting corresponding positions to null.
279 nulls = AlignedBuffer::allocate<bool>(rows.size(), pool, bits::kNull);
280 // Set the active rows to non-null.
281 rows.clearNulls(nulls);
282 if (wrapNulls_) {
283 // Add the nulls from the wrapping.
284 bits::andBits(
285 nulls->asMutable<uint64_t>(),
286 wrapNulls_->as<uint64_t>(),
287 rows.begin(),
288 rows.end());
289 }
290 // Reset nulls buffer if all positions happen to be non-null.
291 if (bits::isAllSet(
292 nulls->as<uint64_t>(), 0, rows.end(), bits::kNotNull)) {
293 nulls.reset();
294 }
295 } else {
296 nulls = wrapNulls_;
297 }
298 wrappedResult = BaseVector::wrapInDictionary(
299 std::move(nulls), wrap_, rows.end(), std::move(peeledResult));
300 }
301 } else {
302 wrappedResult = BaseVector::wrapInConstant(
303 rows.size(), constantWrapIndex_, std::move(peeledResult));
304 }
305 return wrappedResult;
306}
307} // namespace bytedance::bolt::exec

Callers 5

evalEncodingsMethod · 0.45
applyMethod · 0.45
applyMethod · 0.45
TEST_PFunction · 0.45

Calls 9

andBitsFunction · 0.85
isAllSetFunction · 0.85
wrapInDictionaryFunction · 0.85
isAllSelectedMethod · 0.80
sizeMethod · 0.45
clearNullsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
resetMethod · 0.45

Tested by 1

TEST_PFunction · 0.36