summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-10-22 08:45:49 +0000
committerArne Juul <arnej@verizonmedia.com>2020-10-22 08:47:52 +0000
commit5f4ab4a2a1520970ea8e3a97f0561c2a9bd8fffc (patch)
treed4c28704f3f7d115d1d648ba0257186af271bc1b /eval
parent586bd37f9e063edb69a3323720ec83039094c7a3 (diff)
special case "number map"
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/instruction/generic_map.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/eval/src/vespa/eval/instruction/generic_map.cpp b/eval/src/vespa/eval/instruction/generic_map.cpp
index 689339af5b3..272c8b7fc35 100644
--- a/eval/src/vespa/eval/instruction/generic_map.cpp
+++ b/eval/src/vespa/eval/instruction/generic_map.cpp
@@ -32,8 +32,19 @@ void my_generic_map_op(State &state, uint64_t param_in) {
state.pop_push(result_ref);
}
+template <typename Func>
+void my_double_map_op(State &state, uint64_t param_in) {
+ Func function(to_map_fun(param_in));
+ const Value &a = state.peek(0);
+ state.pop_push(state.stash.create<DoubleValue>(function(a.as_double())));
+}
+
struct SelectGenericMapOp {
- template <typename CT, typename Func> static auto invoke() {
+ template <typename CT, typename Func> static auto invoke(const ValueType &type) {
+ if (type.is_double()) {
+ assert((std::is_same<CT,double>::value));
+ return my_double_map_op<Func>;
+ }
return my_generic_map_op<CT, Func>;
}
};
@@ -75,7 +86,7 @@ using MapTypify = TypifyValue<TypifyCellType,operation::TypifyOp1>;
InterpretedFunction::Instruction
GenericMap::make_instruction(const ValueType &lhs_type, map_fun_t function)
{
- auto op = typify_invoke<2,MapTypify,SelectGenericMapOp>(lhs_type.cell_type(), function);
+ auto op = typify_invoke<2,MapTypify,SelectGenericMapOp>(lhs_type.cell_type(), function, lhs_type);
return Instruction(op, to_param(function));
}