diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-15 07:25:58 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-15 13:12:37 +0100 |
commit | d6afedc9a1102d0d02cf92daa5d08b944fdd9349 (patch) | |
tree | 6e3f5435ae5bc355f53715d85c1cfed017e5ebdb | |
parent | 2523fa2064bb09005f747fa3bcafe7a731241e98 (diff) |
Explicit instantiation of common maps/sets.
20 files changed, 73 insertions, 48 deletions
diff --git a/document/src/vespa/document/select/valuenode.cpp b/document/src/vespa/document/select/valuenode.cpp index f473b21147a..2138b8eac41 100644 --- a/document/src/vespa/document/select/valuenode.cpp +++ b/document/src/vespa/document/select/valuenode.cpp @@ -10,7 +10,6 @@ #include <vespa/document/util/stringutil.h> #include <vespa/vespalib/text/lowercase.h> #include <regex> -#include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/log/log.h> LOG_SETUP(".document.select.valuenode"); diff --git a/document/src/vespa/document/update/assignfieldpathupdate.cpp b/document/src/vespa/document/update/assignfieldpathupdate.cpp index cf2da086190..0a676c88df2 100644 --- a/document/src/vespa/document/update/assignfieldpathupdate.cpp +++ b/document/src/vespa/document/update/assignfieldpathupdate.cpp @@ -7,7 +7,6 @@ #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/exceptions.h> #include <boost/numeric/conversion/cast.hpp> -#include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/log/log.h> LOG_SETUP(".document.update.fieldpathupdate"); diff --git a/juniper/src/vespa/juniper/stringmap.cpp b/juniper/src/vespa/juniper/stringmap.cpp index 1b4ce63f397..75106fc23f8 100644 --- a/juniper/src/vespa/juniper/stringmap.cpp +++ b/juniper/src/vespa/juniper/stringmap.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "stringmap.h" -#include <vespa/vespalib/stllike/hash_map.hpp> void Fast_StringMap::Insert(const char* key, const char* value) { diff --git a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp index c2404e88a7b..75c83283c2c 100644 --- a/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp +++ b/persistence/src/vespa/persistence/dummyimpl/dummypersistence.cpp @@ -952,3 +952,5 @@ DummyPersistence::releaseBucketNoLock(const BucketContent& bc) const } // dummy } // spi } // storage + +VESPALIB_HASH_MAP_INSTANTIATE_H(storage::spi::Bucket, vespalib::LinkedPtr<storage::spi::dummy::BucketContent>, document::BucketId::hash)
\ No newline at end of file diff --git a/searchcommon/src/vespa/searchcommon/common/schema.cpp b/searchcommon/src/vespa/searchcommon/common/schema.cpp index af1014fb167..a7dbca8ba8c 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.cpp +++ b/searchcommon/src/vespa/searchcommon/common/schema.cpp @@ -4,7 +4,7 @@ #include <fstream> #include <vespa/config/common/configparser.h> #include <vespa/vespalib/stllike/asciistream.h> -#include <vespa/vespalib/stllike/hash_map.hpp> + #include <vespa/log/log.h> LOG_SETUP(".index.schema"); diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp index 2434b51cc28..0039ee005d7 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_weighted_set_blueprint.cpp @@ -2,10 +2,7 @@ #include "attribute_weighted_set_blueprint.h" -#include "attributevector.h" -#include "attributeguard.h" #include <vespa/searchlib/queryeval/weighted_set_term_search.h> -#include <vespa/vespalib/stllike/hash_map.hpp> namespace search { diff --git a/searchlib/src/vespa/searchlib/attribute/changevector.hpp b/searchlib/src/vespa/searchlib/attribute/changevector.hpp index c23a53c7412..c96829b931c 100644 --- a/searchlib/src/vespa/searchlib/attribute/changevector.hpp +++ b/searchlib/src/vespa/searchlib/attribute/changevector.hpp @@ -4,7 +4,6 @@ #include "changevector.h" #include <vespa/vespalib/util/array.hpp> -#include <vespa/vespalib/stllike/hash_map.hpp> namespace search { diff --git a/searchlib/src/vespa/searchlib/attribute/diversity.h b/searchlib/src/vespa/searchlib/attribute/diversity.h index a67e2cf8f8b..e1914b344a7 100644 --- a/searchlib/src/vespa/searchlib/attribute/diversity.h +++ b/searchlib/src/vespa/searchlib/attribute/diversity.h @@ -4,7 +4,7 @@ #include "singleenumattribute.h" #include "singlenumericattribute.h" -#include <vespa/vespalib/stllike/hash_map.hpp> +#include <vespa/vespalib/stllike/hash_map.h> /** * This file contains low-level code used to implement diversified diff --git a/searchlib/src/vespa/searchlib/attribute/postingchange.cpp b/searchlib/src/vespa/searchlib/attribute/postingchange.cpp index 27de73908ac..a1d2545adb4 100644 --- a/searchlib/src/vespa/searchlib/attribute/postingchange.cpp +++ b/searchlib/src/vespa/searchlib/attribute/postingchange.cpp @@ -5,7 +5,6 @@ #include "multi_value_mapping.h" #include "postinglistattribute.h" #include <vespa/vespalib/util/array.hpp> -#include <vespa/vespalib/stllike/hash_map.hpp> namespace search { diff --git a/searchlib/src/vespa/searchlib/common/condensedbitvectors.cpp b/searchlib/src/vespa/searchlib/common/condensedbitvectors.cpp index ea10403c3ea..2c19e3ff7e9 100644 --- a/searchlib/src/vespa/searchlib/common/condensedbitvectors.cpp +++ b/searchlib/src/vespa/searchlib/common/condensedbitvectors.cpp @@ -1,8 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/searchlib/common/condensedbitvectors.h> +#include "condensedbitvectors.h" #include <vespa/searchlib/common/rcuvector.h> #include <vespa/vespalib/util/exceptions.h> -#include <vespa/vespalib/stllike/hash_map.hpp> using vespalib::IllegalArgumentException; using vespalib::make_string; diff --git a/searchlib/src/vespa/searchlib/fef/properties.cpp b/searchlib/src/vespa/searchlib/fef/properties.cpp index cf0cbe2d1d5..b501a445d91 100644 --- a/searchlib/src/vespa/searchlib/fef/properties.cpp +++ b/searchlib/src/vespa/searchlib/fef/properties.cpp @@ -2,6 +2,7 @@ #include "properties.h" #include <vespa/vespalib/stllike/hash_map.hpp> +#include <vespa/vespalib/stllike/hash_map_equal.hpp> namespace search { namespace fef { @@ -11,13 +12,11 @@ const Property::Values Property::_emptyValues; Property::Property(const Property::Values &values) : _values(&values) -{ -} +{ } Property::Property() : _values(&_emptyValues) -{ -} +{ } bool Property::found() const diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map.cpp b/vespalib/src/vespa/vespalib/stllike/hash_map.cpp index ecc86207a5a..3bfc571520f 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_map.cpp +++ b/vespalib/src/vespa/vespalib/stllike/hash_map.cpp @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "hash_map.hpp" +#include "hash_map_equal.hpp" +#include <vespa/vespalib/util/array_equal.hpp> namespace vespalib { } @@ -11,7 +13,10 @@ VESPALIB_HASH_MAP_INSTANTIATE(vespalib::string, uint32_t); VESPALIB_HASH_MAP_INSTANTIATE(vespalib::string, uint64_t); VESPALIB_HASH_MAP_INSTANTIATE(vespalib::string, double); VESPALIB_HASH_MAP_INSTANTIATE(int64_t, int32_t); +VESPALIB_HASH_MAP_INSTANTIATE(int64_t, uint32_t); +VESPALIB_HASH_MAP_INSTANTIATE(int32_t, uint32_t); VESPALIB_HASH_MAP_INSTANTIATE(uint32_t, int32_t); VESPALIB_HASH_MAP_INSTANTIATE(uint32_t, uint32_t); VESPALIB_HASH_MAP_INSTANTIATE(uint64_t, uint32_t); VESPALIB_HASH_MAP_INSTANTIATE(double, uint32_t); +VESPALIB_HASH_MAP_INSTANTIATE(float, uint32_t); diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map.hpp b/vespalib/src/vespa/vespalib/stllike/hash_map.hpp index 0a97a1f17f1..77ecefef845 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_map.hpp +++ b/vespalib/src/vespa/vespalib/stllike/hash_map.hpp @@ -15,19 +15,6 @@ template <typename K, typename V, typename H, typename EQ, typename M> hash_map<K, V, H, EQ, M>::~hash_map() { } template <typename K, typename V, typename H, typename EQ, typename M> -bool -hash_map<K, V, H, EQ, M>::operator ==(const hash_map & rhs) const { - bool identical(rhs.size() == size()); - if (identical) { - for(const_iterator at(begin()), mat(end()); identical && at != mat; at++) { - const_iterator bt = rhs.find(at->first); - identical = (bt != rhs.end()) && (*at == *bt); - } - } - return identical; -} - -template <typename K, typename V, typename H, typename EQ, typename M> typename hash_map<K, V, H, EQ, M>::insert_result hash_map<K, V, H, EQ, M>::insert(const value_type & value) { return _ht.insert(value); @@ -82,9 +69,12 @@ hash_map<K, V, H, EQ, M>::getMemoryUsed() const } -#define VESPALIB_HASH_MAP_INSTANTIATE(K, V) \ - template class vespalib::hash_map<K, V>; \ - template class vespalib::hashtable<K, std::pair<K,V>, vespalib::hash<K>, std::equal_to<K>, std::_Select1st<std::pair<K,V>>>; \ - template vespalib::hashtable<K, std::pair<K,V>, vespalib::hash<K>, std::equal_to<K>, std::_Select1st<std::pair<K,V>>>::insert_result \ - vespalib::hashtable<K, std::pair<K,V>, vespalib::hash<K>, std::equal_to<K>, std::_Select1st<std::pair<K,V>>>::insert(std::pair<K,V> &&); \ +#define VESPALIB_HASH_MAP_INSTANTIATE_H(K, V, H) \ + template class vespalib::hash_map<K, V, H>; \ + template class vespalib::hashtable<K, std::pair<K,V>, H, std::equal_to<K>, std::_Select1st<std::pair<K,V>>>; \ + template vespalib::hashtable<K, std::pair<K,V>, H, std::equal_to<K>, std::_Select1st<std::pair<K,V>>>::insert_result \ + vespalib::hashtable<K, std::pair<K,V>, H, std::equal_to<K>, std::_Select1st<std::pair<K,V>>>::insert(std::pair<K,V> &&); \ template class vespalib::Array<vespalib::hash_node<std::pair<K,V>>>; + +#define VESPALIB_HASH_MAP_INSTANTIATE(K, V) VESPALIB_HASH_MAP_INSTANTIATE_H(K, V, vespalib::hash<K>) + diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map_equal.hpp b/vespalib/src/vespa/vespalib/stllike/hash_map_equal.hpp new file mode 100644 index 00000000000..b7b40b1307a --- /dev/null +++ b/vespalib/src/vespa/vespalib/stllike/hash_map_equal.hpp @@ -0,0 +1,21 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include "hash_map.h" + +namespace vespalib { + +template <typename K, typename V, typename H, typename EQ, typename M> +bool +hash_map<K, V, H, EQ, M>::operator ==(const hash_map & rhs) const { + bool identical(rhs.size() == size()); + if (identical) { + for(const_iterator at(begin()), mat(end()); identical && at != mat; at++) { + const_iterator bt = rhs.find(at->first); + identical = (bt != rhs.end()) && (*at == *bt); + } + } + return identical; +} + +} diff --git a/vespalib/src/vespa/vespalib/stllike/hash_set.cpp b/vespalib/src/vespa/vespalib/stllike/hash_set.cpp index ef0c0e6188e..506e17828c4 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_set.cpp +++ b/vespalib/src/vespa/vespalib/stllike/hash_set.cpp @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "hash_set.hpp" +#include <vespa/vespalib/util/array_equal.hpp> namespace vespalib { } @@ -11,4 +12,4 @@ VESPALIB_HASH_SET_INSTANTIATE(uint64_t); VESPALIB_HASH_SET_INSTANTIATE(double); VESPALIB_HASH_SET_INSTANTIATE(vespalib::string); VESPALIB_HASH_SET_INSTANTIATE(std::string); -VESPALIB_HASH_SET_INSTANTIATE(const void *);
\ No newline at end of file +VESPALIB_HASH_SET_INSTANTIATE(const void *); diff --git a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor.cpp b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor.cpp index 0e83061a88a..4387b4b1fad 100644 --- a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor.cpp +++ b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor.cpp @@ -10,6 +10,8 @@ #include <vespa/vespalib/tensor/tensor_visitor.h> #include <vespa/vespalib/eval/operation.h> #include <vespa/vespalib/stllike/hash_map.hpp> +#include <vespa/vespalib/stllike/hash_map_equal.hpp> +#include <vespa/vespalib/util/array_equal.hpp> #include <sstream> using vespalib::eval::TensorSpec; diff --git a/vespalib/src/vespa/vespalib/util/array.cpp b/vespalib/src/vespa/vespalib/util/array.cpp index 364e87d8a66..529b668f0a8 100644 --- a/vespalib/src/vespa/vespalib/util/array.cpp +++ b/vespalib/src/vespa/vespalib/util/array.cpp @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "array.hpp" +#include "array_equal.hpp" namespace vespalib { diff --git a/vespalib/src/vespa/vespalib/util/array.h b/vespalib/src/vespa/vespalib/util/array.h index 4d0699c7886..4f404a55edf 100644 --- a/vespalib/src/vespa/vespalib/util/array.h +++ b/vespalib/src/vespa/vespalib/util/array.h @@ -137,7 +137,7 @@ public: T & operator [] (size_t i) { return *array(i); } const T & operator [] (size_t i) const { return *array(i); } bool operator == (const Array & rhs) const; - bool operator != (const Array & rhs) const { return !(*this == rhs); } + bool operator != (const Array & rhs) const; private: T * array(size_t i) { return static_cast<T *>(_array.get()) + i; } const T * array(size_t i) const { return static_cast<const T *>(_array.get()) + i; } diff --git a/vespalib/src/vespa/vespalib/util/array.hpp b/vespalib/src/vespa/vespalib/util/array.hpp index a7194c95014..dbdda73ad66 100644 --- a/vespalib/src/vespa/vespalib/util/array.hpp +++ b/vespalib/src/vespa/vespalib/util/array.hpp @@ -94,18 +94,6 @@ void Array<T>::reserve(size_t n) { } template <typename T> -bool Array<T>::operator ==(const Array & rhs) const -{ - bool retval(size() == rhs.size()); - for (size_t i(0); retval && (i < _sz); i++) { - if ( ! (*array(i) == rhs[i]) ) { - retval = false; - } - } - return retval; -} - -template <typename T> void Array<T>::resize(size_t n) { if (n > capacity()) { diff --git a/vespalib/src/vespa/vespalib/util/array_equal.hpp b/vespalib/src/vespa/vespalib/util/array_equal.hpp new file mode 100644 index 00000000000..0c790191b99 --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/array_equal.hpp @@ -0,0 +1,25 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include "array.h" + +namespace vespalib { + +template <typename T> +bool Array<T>::operator ==(const Array & rhs) const +{ + bool retval(size() == rhs.size()); + for (size_t i(0); retval && (i < _sz); i++) { + if ( ! (*array(i) == rhs[i]) ) { + retval = false; + } + } + return retval; +} + +template <typename T> +bool Array<T>::operator != (const Array & rhs) const { + return !(*this == rhs); +} + +} |