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

Method applyFunctionWithPeeling

bolt/expression/Expr.cpp:1498–1543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1496}
1497
1498bool Expr::applyFunctionWithPeeling(
1499 const SelectivityVector& applyRows,
1500 EvalCtx& context,
1501 VectorPtr& result) {
1502 LocalDecodedVector localDecoded(context);
1503 LocalSelectivityVector newRowsHolder(context);
1504 // Attempt peeling.
1505 std::vector<VectorPtr> peeledVectors;
1506 auto peeledEncoding = PeeledEncoding::peel(
1507 inputValues_,
1508 applyRows,
1509 localDecoded,
1510 vectorFunction_->isDefaultNullBehavior(),
1511 peeledVectors);
1512 if (!peeledEncoding) {
1513 return false;
1514 }
1515 inputValues_ = std::move(peeledVectors);
1516 peeledVectors.clear();
1517
1518 // Translate the relevant rows.
1519 // Note: We do not need to translate final selection since at this stage those
1520 // rows are not used but isFinalSelection() is only used to check whether
1521 // pre-existing rows need to be preserved.
1522 auto newRows = peeledEncoding->translateToInnerRows(applyRows, newRowsHolder);
1523
1524 withContextSaver([&](ContextSaver& saver) {
1525 // Save context and set the peel.
1526 context.saveAndReset(saver, applyRows);
1527 context.setPeeledEncoding(peeledEncoding);
1528
1529 // Apply the function.
1530 VectorPtr peeledResult;
1531 applyFunction(*newRows, context, peeledResult);
1532 VectorPtr wrappedResult = context.getPeeledEncoding()->wrap(
1533 this->type(), context.pool(), peeledResult, applyRows);
1534 context.moveOrCopyResult(wrappedResult, applyRows, result);
1535
1536 // Recycle peeledResult if it's not owned by the result vector. Examples of
1537 // when this can happen is when the result is a primitive constant vector,
1538 // or when moveOrCopyResult copies wrappedResult content.
1539 context.releaseVector(peeledResult);
1540 });
1541
1542 return true;
1543}
1544
1545void Expr::applyFunction(
1546 const SelectivityVector& rows,

Callers

nothing calls this directly

Calls 9

withContextSaverFunction · 0.85
translateToInnerRowsMethod · 0.80
saveAndResetMethod · 0.80
releaseVectorMethod · 0.80
isDefaultNullBehaviorMethod · 0.45
clearMethod · 0.45
wrapMethod · 0.45
typeMethod · 0.45
poolMethod · 0.45

Tested by

no test coverage detected