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

Method applyFunction

bolt/expression/Expr.cpp:1545–1644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1543 f->evalSpecialForm(rows, context, &v);
1544 args.emplace_back(std::move(v));
1545 }
1546
1547 // TODO: string vector ?
1548 BaseVector::ensureWritable(rows, type(), context->pool(), result);
1549
1550 // Apply JITed vector function
1551 jitVectorFunction_(args, result);
1552
1553 // Now, handle SelectivityVector
1554 // TODO:
1555 // 1. evaluate non-compilable sub expressions as inputs
1556 // 2. visit the expr tree for defaultNulls
1557 bool defaultNulls = vectorFunction_ != nullptr
1558 ? vectorFunction_->isDefaultNullBehavior()
1559 : true;
1560 auto* remainingRows = &rows;
1561 LocalSelectivityVector nonNulls(context);
1562
1563 for (auto&& arg : args) {
1564 if (defaultNulls && arg->mayHaveNulls()) {
1565 if (remainingRows == &rows) {
1566 nonNulls.allocate(rows.end());
1567 *nonNulls.get() = rows;
1568 remainingRows = nonNulls.get();
1569 }
1570 nonNulls.get()->deselectNulls(
1571 arg->flatRawNulls(rows),
1572 remainingRows->begin(),
1573 remainingRows->end());
1574 if (!remainingRows->hasSelections()) {
1575 inputValues_.clear();
1576 setAllNulls(rows, context, result);
1577 return;
1578 }
1579 }
1580 }
1581 if (remainingRows != &rows) {
1582 addNulls(rows, remainingRows->asRange().bits(), context, result);
1583 }
1584
1585 return;
1586 }
1587#endif
1588
1589 computeIsAsciiForInputs(vectorFunction_.get(), inputValues_, rows);
1590 auto isAscii = type()->isVarchar()
1591 ? computeIsAsciiForResult(vectorFunction_.get(), inputValues_, rows)
1592 : std::nullopt;
1593
1594 try {
1595 vectorFunction_->apply(rows, inputValues_, type(), context, result);
1596 } catch (const BoltException& ve) {
1597 throw;
1598 } catch (const std::exception& e) {
1599 BOLT_USER_FAIL(e.what());
1600 }
1601
1602 if (!result) {

Callers

nothing calls this directly

Calls 15

ensureWritableFunction · 0.85
computeIsAsciiForInputsFunction · 0.85
computeIsAsciiForResultFunction · 0.85
countSelectedMethod · 0.80
hasSelectionsMethod · 0.80
setErrorsMethod · 0.80
has_valueMethod · 0.80
setIsAsciiMethod · 0.80
typeEnum · 0.50
evalSpecialFormMethod · 0.45
poolMethod · 0.45
isDefaultNullBehaviorMethod · 0.45

Tested by

no test coverage detected