diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-20 18:15:32 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-20 18:15:32 +0000 |
commit | 37c0e98af2ab7fbeb307019a20e572def4f1ddb6 (patch) | |
tree | 02312684c58dea559b7ade43ab30abc86c9ea0a8 /eval | |
parent | b693d572df945b9e82798e0c40b8b7b565f6a4a8 (diff) |
Separate where you nede an actual hash, and where you want the string hashed to a double.
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/eval/basic_nodes.h | 5 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/key_gen.cpp | 6 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp | 5 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/make_tensor_function.cpp | 2 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/test/eval_spec.cpp | 10 | ||||
-rw-r--r-- | eval/src/vespa/eval/eval/test/reference_evaluation.cpp | 2 |
6 files changed, 14 insertions, 16 deletions
diff --git a/eval/src/vespa/eval/eval/basic_nodes.h b/eval/src/vespa/eval/eval/basic_nodes.h index 2db00bbcb7d..af6ee24289a 100644 --- a/eval/src/vespa/eval/eval/basic_nodes.h +++ b/eval/src/vespa/eval/eval/basic_nodes.h @@ -6,6 +6,7 @@ #include "string_stuff.h" #include <vespa/vespalib/util/hdr_abort.h> #include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/stllike/hash_fun.h> #include <vespa/vespalib/util/string_hash.h> #include <memory> #include <map> @@ -120,9 +121,9 @@ private: public: String(const vespalib::string &value_in) : _value(value_in) {} bool is_const_double() const override { return true; } - double get_const_double_value() const override { return hash(); } + double get_const_double_value() const override { return hash2d(_value); } const vespalib::string &value() const { return _value; } - uint32_t hash() const { return hash_code(_value.data(), _value.size()); } + uint64_t hash() const { return hashValue(_value.data(), _value.size()); } vespalib::string dump(DumpContext &) const override { return as_quoted_string(_value); } diff --git a/eval/src/vespa/eval/eval/key_gen.cpp b/eval/src/vespa/eval/eval/key_gen.cpp index a8f9700e865..6bf61f5336e 100644 --- a/eval/src/vespa/eval/eval/key_gen.cpp +++ b/eval/src/vespa/eval/eval/key_gen.cpp @@ -4,8 +4,7 @@ #include "node_visitor.h" #include "node_traverser.h" -namespace vespalib { -namespace eval { +namespace vespalib::eval { using namespace nodes; @@ -106,5 +105,4 @@ vespalib::string gen_key(const Function &function, PassParams pass_params) return key_gen.key; } -} // namespace vespalib::eval -} // namespace vespalib +} diff --git a/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp b/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp index 158bc91dd6a..3fafb8f8b18 100644 --- a/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp +++ b/eval/src/vespa/eval/eval/llvm/llvm_wrapper.cpp @@ -12,7 +12,6 @@ #include <llvm/IR/IRBuilder.h> #include <llvm/IR/Intrinsics.h> #include <llvm/ExecutionEngine/ExecutionEngine.h> -#include <llvm/Analysis/Passes.h> #include <llvm/IR/DataLayout.h> #include <llvm/Transforms/Scalar.h> #include <llvm/Transforms/IPO/PassManagerBuilder.h> @@ -176,7 +175,7 @@ struct FunctionBuilder : public NodeVisitor, public NodeTraverser { params.push_back(&(*itr)); } } - ~FunctionBuilder(); + ~FunctionBuilder() override; //------------------------------------------------------------------------- @@ -385,7 +384,7 @@ struct FunctionBuilder : public NodeVisitor, public NodeTraverser { push(get_param(item.id())); } void visit(const String &item) override { - push_double(item.hash()); + push_double(item.get_const_double_value()); } void visit(const In &item) override { llvm::Value *lhs = pop_double(); diff --git a/eval/src/vespa/eval/eval/make_tensor_function.cpp b/eval/src/vespa/eval/eval/make_tensor_function.cpp index 1386196e719..72e8ac6cbde 100644 --- a/eval/src/vespa/eval/eval/make_tensor_function.cpp +++ b/eval/src/vespa/eval/eval/make_tensor_function.cpp @@ -167,7 +167,7 @@ struct TensorFunctionBuilder : public NodeVisitor, public NodeTraverser { make_inject(node, node.id()); } void visit(const String &node) override { - make_const(node, stash.create<DoubleValue>(node.hash())); + make_const(node, stash.create<DoubleValue>(node.get_const_double_value())); } void visit(const In &node) override { auto my_in = std::make_unique<In>(std::make_unique<Symbol>(0)); diff --git a/eval/src/vespa/eval/eval/test/eval_spec.cpp b/eval/src/vespa/eval/eval/test/eval_spec.cpp index 02e9c34a75e..3bd9df18438 100644 --- a/eval/src/vespa/eval/eval/test/eval_spec.cpp +++ b/eval/src/vespa/eval/eval/test/eval_spec.cpp @@ -124,11 +124,11 @@ EvalSpec::add_terminal_cases() { add_expression({}, "10").add_case({}, 10.0); add_expression({}, "100").add_case({}, 100.0); add_rule({"a", -5.0, 5.0}, "a", [](double a){ return a; }); - add_expression({}, "\"\"").add_case({}, vespalib::hash_code("")); - add_expression({}, "\"foo\"").add_case({}, vespalib::hash_code("foo")); - add_expression({}, "\"foo bar baz\"").add_case({}, vespalib::hash_code("foo bar baz")); - add_expression({}, "\">\\\\\\\"\\t\\n\\r\\f<\"").add_case({}, vespalib::hash_code(">\\\"\t\n\r\f<")); - add_expression({}, "\">\\x08\\x10\\x12\\x14<\"").add_case({}, vespalib::hash_code(">\x08\x10\x12\x14<")); + add_expression({}, "\"\"").add_case({}, vespalib::hash2d("")); + add_expression({}, "\"foo\"").add_case({}, vespalib::hash2d("foo")); + add_expression({}, "\"foo bar baz\"").add_case({}, vespalib::hash2d("foo bar baz")); + add_expression({}, "\">\\\\\\\"\\t\\n\\r\\f<\"").add_case({}, vespalib::hash2d(">\\\"\t\n\r\f<")); + add_expression({}, "\">\\x08\\x10\\x12\\x14<\"").add_case({}, vespalib::hash2d(">\x08\x10\x12\x14<")); } void diff --git a/eval/src/vespa/eval/eval/test/reference_evaluation.cpp b/eval/src/vespa/eval/eval/test/reference_evaluation.cpp index da0f5a1d1f0..acbc7463e28 100644 --- a/eval/src/vespa/eval/eval/test/reference_evaluation.cpp +++ b/eval/src/vespa/eval/eval/test/reference_evaluation.cpp @@ -145,7 +145,7 @@ struct EvalNode : public NodeVisitor { eval_param(node.id()); } void visit(const String &node) override { - eval_const(num(node.hash())); + eval_const(num(node.get_const_double_value())); } void visit(const In &node) override { auto my_op1 = [&](double a) { |