diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-01-10 12:36:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-10 12:36:12 +0100 |
commit | e3c842c8f7271126cb9e869937da907c4ddfd312 (patch) | |
tree | 13f6b9fc34d1a2957af7e36e2d5eb3fa70965275 | |
parent | 0c63284f9b2dbd94f25c975aeb6eadd36ea93d81 (diff) | |
parent | 6cea4e181685508b120ee559d3a9ba2191f5379c (diff) |
Merge pull request #4602 from vespa-engine/balder/use-xxhash32-for-sparse-tensor
Balder/use xxhash32 for sparse tensor
-rw-r--r-- | eval/src/tests/tensor/tensor_slime_serialization/tensor_slime_serialization_test.cpp | 4 | ||||
-rw-r--r-- | eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h | 18 |
2 files changed, 9 insertions, 13 deletions
diff --git a/eval/src/tests/tensor/tensor_slime_serialization/tensor_slime_serialization_test.cpp b/eval/src/tests/tensor/tensor_slime_serialization/tensor_slime_serialization_test.cpp index e6e6c7de686..2b75503c534 100644 --- a/eval/src/tests/tensor/tensor_slime_serialization/tensor_slime_serialization_test.cpp +++ b/eval/src/tests/tensor/tensor_slime_serialization/tensor_slime_serialization_test.cpp @@ -63,8 +63,8 @@ vespalib::string twoCellsJson[3] = "] }", "{ dimensions: [ 'x', 'y' ]," " cells: [" - "{ address: { x:'1'}, value: 3.0 }," - "{ address: { y:'3'}, value: 4.0 }" + "{ address: { y:'3'}, value: 4.0 }," + "{ address: { x:'1'}, value: 3.0 }" "] }", }; } diff --git a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h index 321690085be..b179b431b94 100644 --- a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h +++ b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_address_ref.h @@ -3,14 +3,10 @@ #pragma once #include <vespa/vespalib/util/stash.h> +#include <vespa/vespalib/xxhash/xxhash.h> #include <cstring> -namespace vespalib { - -// From vespalib/util/hashmap.h -size_t hashValue(const void * buf, size_t sz); - -namespace tensor { +namespace vespalib::tensor { /** * A reference to a compact sparse immutable address to a tensor cell. @@ -18,8 +14,8 @@ namespace tensor { class SparseTensorAddressRef { const void *_start; - uint32_t _size; - uint32_t _hash; + uint32_t _size; + uint32_t _hash; public: SparseTensorAddressRef() : _start(nullptr), _size(0u), _hash(0u) @@ -44,7 +40,7 @@ public: uint32_t hash() const { return _hash; } - uint32_t calcHash() const { return hashValue(_start, _size); } + uint32_t calcHash() const { return XXH32(_start, _size, 0); } bool operator<(const SparseTensorAddressRef &rhs) const { size_t minSize = std::min(_size, rhs._size); @@ -67,5 +63,5 @@ public: uint32_t size() const { return _size; } }; -} // namespace vespalib::tensor -} // namespace vespalib +} + |