diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-15 12:47:01 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-15 13:12:37 +0100 |
commit | d7328b4a31cba1f7c99366e7f8ad1f0ee709d048 (patch) | |
tree | 59c801c5a5184b785794b36be5ef74ea94256f36 | |
parent | 6409f3bcc0ae7fafa057fdd94a5025d25a69769c (diff) |
Complete the split also for tests.
20 files changed, 99 insertions, 74 deletions
diff --git a/metrics/src/vespa/metrics/loadmetric.h b/metrics/src/vespa/metrics/loadmetric.h index 1ab726a844c..d31ef5efca4 100644 --- a/metrics/src/vespa/metrics/loadmetric.h +++ b/metrics/src/vespa/metrics/loadmetric.h @@ -56,20 +56,7 @@ public: MetricType& operator[](const LoadType& type) { return getMetric(type); } const MetricType& operator[](const LoadType& type) const { return const_cast<LoadMetric<MetricType>*>(this)->getMetric(type); } - MetricType& getMetric(const LoadType& type) { - MetricType* metric; - - typename vespalib::hash_map<uint32_t, MetricTypeLP>::iterator it( - _metrics.find(type.getId())); - if (it == _metrics.end()) { - it = _metrics.find(0); - assert(it != _metrics.end()); // Default should always exist - } - metric = it->second.get(); - assert(metric); - - return *metric; - } + MetricType& getMetric(const LoadType& type); void addMemoryUsage(MemoryConsumption& mc) const override; }; diff --git a/metrics/src/vespa/metrics/loadmetric.hpp b/metrics/src/vespa/metrics/loadmetric.hpp index e1faa756be1..54171341b67 100644 --- a/metrics/src/vespa/metrics/loadmetric.hpp +++ b/metrics/src/vespa/metrics/loadmetric.hpp @@ -69,6 +69,23 @@ LoadMetric<MetricType>::clone(std::vector<Metric::LP>& ownerList, } template<typename MetricType> +MetricType& +LoadMetric<MetricType>::getMetric(const LoadType& type) { + MetricType* metric; + + typename vespalib::hash_map<uint32_t, MetricTypeLP>::iterator it( + _metrics.find(type.getId())); + if (it == _metrics.end()) { + it = _metrics.find(0); + assert(it != _metrics.end()); // Default should always exist + } + metric = it->second.get(); + assert(metric); + + return *metric; +} + +template<typename MetricType> void LoadMetric<MetricType>::addMemoryUsage(MemoryConsumption& mc) const { ++mc._loadMetricCount; diff --git a/searchlib/src/tests/attribute/changevector/changevector_test.cpp b/searchlib/src/tests/attribute/changevector/changevector_test.cpp index 9f0a796fd3e..c9361387401 100644 --- a/searchlib/src/tests/attribute/changevector/changevector_test.cpp +++ b/searchlib/src/tests/attribute/changevector/changevector_test.cpp @@ -1,10 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("changevector_test"); #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/searchlib/attribute/changevector.h> +#include <vespa/searchlib/attribute/changevector.hpp> using namespace search; diff --git a/searchlib/src/tests/memoryindex/compact_document_words_store/compact_document_words_store_test.cpp b/searchlib/src/tests/memoryindex/compact_document_words_store/compact_document_words_store_test.cpp index 662adbf6b94..0c8606ab3a3 100644 --- a/searchlib/src/tests/memoryindex/compact_document_words_store/compact_document_words_store_test.cpp +++ b/searchlib/src/tests/memoryindex/compact_document_words_store/compact_document_words_store_test.cpp @@ -1,11 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".memoryindex.compact_document_words_store_test"); + #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/datastore/entryref.h> #include <vespa/searchlib/memoryindex/compact_document_words_store.h> #include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/stllike/hash_map.hpp> #include <iostream> #include <map> diff --git a/searchlib/src/vespa/searchlib/common/rcuvector.cpp b/searchlib/src/vespa/searchlib/common/rcuvector.cpp index abc59b47a48..5de91fcb448 100644 --- a/searchlib/src/vespa/searchlib/common/rcuvector.cpp +++ b/searchlib/src/vespa/searchlib/common/rcuvector.cpp @@ -15,6 +15,25 @@ template class RcuVectorBase<int64_t>; template class RcuVectorBase<float>; template class RcuVectorBase<double>; +template class RcuVector<uint8_t>; +template class RcuVector<uint16_t>; +template class RcuVector<uint32_t>; +template class RcuVector<int8_t>; +template class RcuVector<int16_t>; +template class RcuVector<int32_t>; +template class RcuVector<int64_t>; +template class RcuVector<float>; +template class RcuVector<double>; + +template class RcuVectorHeld<uint8_t>; +template class RcuVectorHeld<uint16_t>; +template class RcuVectorHeld<uint32_t>; +template class RcuVectorHeld<int8_t>; +template class RcuVectorHeld<int16_t>; +template class RcuVectorHeld<int32_t>; +template class RcuVectorHeld<int64_t>; +template class RcuVectorHeld<float>; +template class RcuVectorHeld<double>; } } diff --git a/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp b/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp index f92fc22d30d..d0900ab9154 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/compact_document_words_store.cpp @@ -3,6 +3,7 @@ #include "compact_document_words_store.h" #include <vespa/searchlib/datastore/datastore.hpp> #include <vespa/vespalib/stllike/hash_map.hpp> + #include <vespa/log/log.h> LOG_SETUP(".memoryindex.compact_document_words_store"); diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_range_term_expander.h b/searchlib/src/vespa/searchlib/predicate/predicate_range_term_expander.h index f422edc32fc..7920b700720 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_range_term_expander.h +++ b/searchlib/src/vespa/searchlib/predicate/predicate_range_term_expander.h @@ -3,6 +3,7 @@ #pragma once #include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/util/exceptions.h> namespace search { namespace predicate { diff --git a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp index 1298791e95e..0c6776d6b39 100644 --- a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp +++ b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp @@ -2,6 +2,7 @@ #pragma once #include "simple_index.h" +#include <vespa/searchlib/common/rcuvector.hpp> namespace search { namespace predicate { diff --git a/storage/src/tests/common/metricstest.cpp b/storage/src/tests/common/metricstest.cpp index 78d820c8802..9c2c8289d58 100644 --- a/storage/src/tests/common/metricstest.cpp +++ b/storage/src/tests/common/metricstest.cpp @@ -1,26 +1,21 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <cppunit/extensions/HelperMacros.h> #include <vespa/document/fieldvalue/document.h> -#include <vespa/document/bucket/bucketid.h> -#include <vespa/log/log.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/storageframework/defaultimplementation/clock/fakeclock.h> #include <vespa/storage/bucketdb/bucketmanager.h> -#include <vespa/storageframework/storageframework.h> #include <vespa/storage/common/statusmetricconsumer.h> #include <vespa/storage/persistence/filestorage/filestormanager.h> #include <vespa/storage/visiting/visitormetrics.h> -#include <vespa/documentapi/loadtypes/loadtype.h> #include <tests/common/teststorageapp.h> #include <tests/common/testhelper.h> #include <tests/common/dummystoragelink.h> -#include <iostream> -#include <chrono> #include <thread> #include <vespa/metrics/metricmanager.h> +#include <vespa/vespalib/stllike/hash_map.hpp> +#include <vespa/log/log.h> LOG_SETUP(".test.metrics"); namespace storage { diff --git a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp index e0d2bae9a44..6dce437033d 100644 --- a/storage/src/tests/persistence/filestorage/operationabortingtest.cpp +++ b/storage/src/tests/persistence/filestorage/operationabortingtest.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <vector> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/storage/persistence/messages.h> @@ -8,7 +7,7 @@ #include <vespa/persistence/dummyimpl/dummypersistence.h> #include <tests/persistence/common/filestortestfixture.h> #include <vespa/vespalib/util/barrier.h> -#include <vespa/vespalib/util/thread.h> +#include <vespa/vespalib/stllike/hash_set_insert.hpp> #include <vespa/log/log.h> LOG_SETUP(".operationabortingtest"); diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map.h b/vespalib/src/vespa/vespalib/stllike/hash_map.h index 12c6d3574e4..51a8151e91a 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_map.h +++ b/vespalib/src/vespa/vespalib/stllike/hash_map.h @@ -37,13 +37,13 @@ public: insert_result insert(const value_type & value); template <typename InputIt> void insert(InputIt first, InputIt last); - const V & operator [] (const K & key) const { return _ht.find(key)->second; } - V & operator [] (const K & key) { return _ht.insert(value_type(key, V())).first->second; } + const V & operator [] (const K & key) const { return _ht.find(key)->second; } + V & operator [] (const K & key) { return _ht.insert(value_type(key, V())).first->second; } void erase(const K & key); - void erase(iterator it) { return erase(it->first); } - void erase(const_iterator it) { return erase(it->first); } - iterator find(const K & key) { return _ht.find(key); } - const_iterator find(const K & key) const { return _ht.find(key); } + void erase(iterator it) { return erase(it->first); } + void erase(const_iterator it) { return erase(it->first); } + iterator find(const K & key) { return _ht.find(key); } + const_iterator find(const K & key) const { return _ht.find(key); } void clear(); void resize(size_t newSize); void swap(hash_map & rhs); diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map.hpp b/vespalib/src/vespa/vespalib/stllike/hash_map.hpp index 77ecefef845..74d39e58c6b 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_map.hpp +++ b/vespalib/src/vespa/vespalib/stllike/hash_map.hpp @@ -1,7 +1,7 @@ // 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" +#include "hash_map_insert.hpp" #include "hashtable.hpp" namespace vespalib { @@ -27,16 +27,6 @@ hash_map<K, V, H, EQ, M>::erase(const K & key) { } template <typename K, typename V, typename H, typename EQ, typename M> -template <typename InputIt> -void -hash_map<K, V, H, EQ, M>::insert(InputIt first, InputIt last) { - while (first != last) { - _ht.insert(*first); - ++first; - } -} - -template <typename K, typename V, typename H, typename EQ, typename M> void hash_map<K, V, H, EQ, M>::clear() { _ht.clear(); diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map_insert.hpp b/vespalib/src/vespa/vespalib/stllike/hash_map_insert.hpp new file mode 100644 index 00000000000..30d07163ce1 --- /dev/null +++ b/vespalib/src/vespa/vespalib/stllike/hash_map_insert.hpp @@ -0,0 +1,18 @@ +// 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> +template <typename InputIt> +void +hash_map<K, V, H, EQ, M>::insert(InputIt first, InputIt last) { + while (first != last) { + insert(*first); + ++first; + } +} + +} diff --git a/vespalib/src/vespa/vespalib/stllike/hash_set.hpp b/vespalib/src/vespa/vespalib/stllike/hash_set.hpp index 98c57a76358..8be7d982e80 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_set.hpp +++ b/vespalib/src/vespa/vespalib/stllike/hash_set.hpp @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "hash_set.h" +#include "hash_set_insert.hpp" #include "hashtable.hpp" namespace vespalib { @@ -17,14 +17,6 @@ hash_set<K, H, EQ, M>::hash_set(size_t reserveSize, const H &hasher, const EQ &e { } template<typename K, typename H, typename EQ, typename M> -template<typename InputIterator> -hash_set<K, H, EQ, M>::hash_set(InputIterator first, InputIterator last) - : _ht(0) -{ - insert(first, last); -} - -template<typename K, typename H, typename EQ, typename M> hash_set<K, H, EQ, M>::hash_set(std::initializer_list<K> input) : _ht(0) { @@ -71,16 +63,6 @@ hash_set<K, H, EQ, M>::getMemoryConsumption() const { } template<typename K, typename H, typename EQ, typename M> -template<typename InputIt> -void -hash_set<K, H, EQ, M>::insert(InputIt first, InputIt last) { - _ht.resize(last - first + capacity()); - for (; first < last; first++) { - _ht.insert(*first); - } -} - -template<typename K, typename H, typename EQ, typename M> void hash_set<K, H, EQ, M>::erase(const K &key) { return _ht.erase(key); diff --git a/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp b/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp new file mode 100644 index 00000000000..a0bd94bafaa --- /dev/null +++ b/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp @@ -0,0 +1,27 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "hash_set.h" + +namespace vespalib { + +template<typename K, typename H, typename EQ, typename M> +template<typename InputIterator> +hash_set<K, H, EQ, M>::hash_set(InputIterator first, InputIterator last) + : _ht(0) +{ + insert(first, last); +} + +template<typename K, typename H, typename EQ, typename M> +template<typename InputIt> +void +hash_set<K, H, EQ, M>::insert(InputIt first, InputIt last) { + _ht.resize(last - first + capacity()); + for (; first < last; first++) { + insert(*first); + } +} + +} diff --git a/vespalib/src/vespa/vespalib/tensor/dense/dense_tensor_builder.cpp b/vespalib/src/vespa/vespalib/tensor/dense/dense_tensor_builder.cpp index 8b41d349d43..db2a4ffaac8 100644 --- a/vespalib/src/vespa/vespalib/tensor/dense/dense_tensor_builder.cpp +++ b/vespalib/src/vespa/vespalib/tensor/dense/dense_tensor_builder.cpp @@ -2,8 +2,6 @@ #include "dense_tensor_builder.h" #include <vespa/vespalib/util/exceptions.h> -#include <vespa/vespalib/util/stringfmt.h> -#include <vespa/vespalib/stllike/hash_map.hpp> using vespalib::IllegalArgumentException; using vespalib::make_string; diff --git a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_builder.cpp b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_builder.cpp index 4092499bf44..beddc79cc9a 100644 --- a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_builder.cpp +++ b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_builder.cpp @@ -1,8 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "sparse_tensor_builder.h" -#include <vespa/vespalib/tensor/tensor.h> -#include <vespa/vespalib/stllike/hash_map.hpp> namespace vespalib { namespace tensor { diff --git a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_match.cpp b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_match.cpp index 4b4378796d0..4add729d290 100644 --- a/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_match.cpp +++ b/vespalib/src/vespa/vespalib/tensor/sparse/sparse_tensor_match.cpp @@ -1,8 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "sparse_tensor_match.h" -#include "sparse_tensor_address_decoder.h" -#include <vespa/vespalib/stllike/hash_map.hpp> namespace vespalib { namespace tensor { diff --git a/vespalib/src/vespa/vespalib/tensor/tensor_apply.cpp b/vespalib/src/vespa/vespalib/tensor/tensor_apply.cpp index ab8c1534a39..8384d997122 100644 --- a/vespalib/src/vespa/vespalib/tensor/tensor_apply.cpp +++ b/vespalib/src/vespa/vespalib/tensor/tensor_apply.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 "tensor_apply.h" -#include <vespa/vespalib/stllike/hash_map.hpp> namespace vespalib { namespace tensor { diff --git a/vespalib/src/vespa/vespalib/tensor/tensor_mapper.cpp b/vespalib/src/vespa/vespalib/tensor/tensor_mapper.cpp index 646377c1d1a..f8a1f99cb5b 100644 --- a/vespalib/src/vespa/vespalib/tensor/tensor_mapper.cpp +++ b/vespalib/src/vespa/vespalib/tensor/tensor_mapper.cpp @@ -7,7 +7,6 @@ #include <vespa/vespalib/tensor/dense/dense_tensor.h> #include "tensor_address_element_iterator.h" #include "default_tensor.h" -#include <vespa/vespalib/stllike/hash_map.hpp> using vespalib::eval::ValueType; |