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

Method apply

bolt/python/Function.cpp:53–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51 }
52
53 void apply(
54 const SelectivityVector& rows,
55 std::vector<VectorPtr>& args,
56 const TypePtr& outputType,
57 exec::EvalCtx& context,
58 VectorPtr& result) const override {
59 pybind11::list pyArgs;
60 if (mapBatch_) {
61 BOLT_CHECK_EQ(defaultArgs_.size(), 0)
62 std::shared_ptr<RowVector> rowVector =
63 bolt::python::combineInputColumns(args, context);
64 pyArgs.append(pybind11::cast(rowVector));
65 } else {
66 pyArgs = bolt::python::asPyArgs(nArgs_, args, defaultArgs_);
67 }
68
69 bolt::python::pyTry<void>(
70 [&]() { result = function_(*pyArgs).cast<VectorPtr>(); },
71 [&]() {
72 return fmt::format(
73 "Failed to evaluate function '{}' with "
74 "arguments: '{}'",
75 bolt::python::pyTypeStr(function_),
76 bolt::python::toString(pyArgs));
77 });
78 // `result` will be allocated from the pool of the `pybolt` python
79 // module. Its lifetime is the same as the one of that module.
80 if (outputType->isPrimitiveType()) {
81 BOLT_CHECK_EQ(result->type(), outputType);
82 } else {
83 BOLT_CHECK(result->type()->equivalent(*outputType))
84 }
85 }
86};
87} // namespace
88

Callers

nothing calls this directly

Calls 10

combineInputColumnsFunction · 0.85
castFunction · 0.85
asPyArgsFunction · 0.85
pyTypeStrFunction · 0.85
toStringFunction · 0.70
sizeMethod · 0.45
appendMethod · 0.45
isPrimitiveTypeMethod · 0.45
typeMethod · 0.45
equivalentMethod · 0.45

Tested by

no test coverage detected