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

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

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