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

Method apply

bolt/expression/tests/ExprTest.cpp:794–824  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792class PlusConstantFunction : public exec::VectorFunction {
793 public:
794 explicit PlusConstantFunction(int32_t addition) : addition_(addition) {}
795
796 void apply(
797 const SelectivityVector& rows,
798 std::vector<VectorPtr>& args,
799 const TypePtr& /* outputType */,
800 exec::EvalCtx& context,
801 VectorPtr& result) const override {
802 BOLT_CHECK_EQ(args.size(), 1);
803
804 auto& arg = args[0];
805
806 // The argument may be flat or constant.
807 BOLT_CHECK(arg->isFlatEncoding() || arg->isConstantEncoding());
808
809 BaseVector::ensureWritable(rows, INTEGER(), context.pool(), result);
810
811 auto flatResult = result->asFlatVector<int32_t>();
812 auto rawResult = flatResult->mutableRawValues();
813
814 flatResult->clearNulls(rows);
815
816 if (arg->isConstantEncoding()) {
817 auto value = arg->as<ConstantVector<int32_t>>()->valueAt(0);
818 rows.applyToSelected(
819 [&](auto row) { rawResult[row] = value + addition_; });
820 } else {
821 auto* rawInput = arg->as<FlatVector<int32_t>>()->rawValues();
822
823 rows.applyToSelected(
824 [&](auto row) { rawResult[row] = rawInput[row] + addition_; });
825 }
826 }
827

Callers

nothing calls this directly

Calls 8

ensureWritableFunction · 0.85
applyToSelectedMethod · 0.80
sizeMethod · 0.45
poolMethod · 0.45
mutableRawValuesMethod · 0.45
clearNullsMethod · 0.45
valueAtMethod · 0.45
rawValuesMethod · 0.45

Tested by

no test coverage detected