| 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 |
nothing calls this directly
no test coverage detected