diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-03-08 10:13:44 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-03-08 10:13:44 +0100 |
commit | 36ba0924c6f40097130b8da0654b0df56f99e882 (patch) | |
tree | 768db5a24561e91ab30d5294cc841b55604993ab | |
parent | b1015bd850fb94157d8c21077578e45628384e02 (diff) |
Move utility code to atomic_utils namespace.
4 files changed, 41 insertions, 30 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/atomic_utils.h b/searchlib/src/vespa/searchlib/attribute/atomic_utils.h new file mode 100644 index 00000000000..48914de8942 --- /dev/null +++ b/searchlib/src/vespa/searchlib/attribute/atomic_utils.h @@ -0,0 +1,34 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +namespace vespalib::datastore { + +class AtomicEntryRef; +class EntryRef; + +} + +namespace search::attribute::atomic_utils { + +/* + * Helper class to map from atomic value to non-atomic value, e.g. + * from AtomicEntryRef to EntryRef. + */ +template <typename MaybeAtomicValue> +class NonAtomicValue { +public: + using type = MaybeAtomicValue; +}; + +template <> +class NonAtomicValue<vespalib::datastore::AtomicEntryRef> +{ +public: + using type = vespalib::datastore::EntryRef; +}; + +template <class MaybeAtomicValue> +using NonAtomicValue_t = typename NonAtomicValue<MaybeAtomicValue>::type; + +} diff --git a/searchlib/src/vespa/searchlib/attribute/load_utils.cpp b/searchlib/src/vespa/searchlib/attribute/load_utils.cpp index 2c53003112a..707cdc6af76 100644 --- a/searchlib/src/vespa/searchlib/attribute/load_utils.cpp +++ b/searchlib/src/vespa/searchlib/attribute/load_utils.cpp @@ -85,12 +85,12 @@ template uint32_t loadFromEnumeratedMultiValue(MultiValueMapping<Value<ValueType #define INSTANTIATE_WSET(ValueType, Saver) \ template uint32_t loadFromEnumeratedMultiValue(MultiValueMapping<WeightedValue<ValueType>> &, ReaderBase &, vespalib::ConstArrayRef<ValueType>, vespalib::ConstArrayRef<uint32_t>, Saver) #define INSTANTIATE_SINGLE(ValueType, Saver) \ -template void loadFromEnumeratedSingleValue(vespalib::RcuVectorBase<ValueType> &, vespalib::GenerationHolder &, ReaderBase &, vespalib::ConstArrayRef<load_utils::NonAtomicValue_t<ValueType>>, vespalib::ConstArrayRef<uint32_t>, Saver) +template void loadFromEnumeratedSingleValue(vespalib::RcuVectorBase<ValueType> &, vespalib::GenerationHolder &, ReaderBase &, vespalib::ConstArrayRef<atomic_utils::NonAtomicValue_t<ValueType>>, vespalib::ConstArrayRef<uint32_t>, Saver) #define INSTANTIATE_SINGLE_ARRAY_WSET(ValueType, Saver) \ INSTANTIATE_SINGLE(ValueType, Saver); \ -INSTANTIATE_ARRAY(load_utils::NonAtomicValue_t<ValueType>, Saver); \ -INSTANTIATE_WSET(load_utils::NonAtomicValue_t<ValueType>, Saver) +INSTANTIATE_ARRAY(atomic_utils::NonAtomicValue_t<ValueType>, Saver); \ +INSTANTIATE_WSET(atomic_utils::NonAtomicValue_t<ValueType>, Saver) #define INSTANTIATE_ENUM(Saver) \ INSTANTIATE_SINGLE_ARRAY_WSET(AtomicEntryRef, Saver) diff --git a/searchlib/src/vespa/searchlib/attribute/load_utils.h b/searchlib/src/vespa/searchlib/attribute/load_utils.h index fe41811dcfa..f9f933f3726 100644 --- a/searchlib/src/vespa/searchlib/attribute/load_utils.h +++ b/searchlib/src/vespa/searchlib/attribute/load_utils.h @@ -2,6 +2,7 @@ #pragma once +#include "atomic_utils.h" #include "attributevector.h" #include "readerbase.h" #include <vespa/vespalib/util/arrayref.h> @@ -15,30 +16,6 @@ class EntryRef; namespace search::attribute { -namespace load_utils { - -/* - * Helper class to map from atomic value to non-atomic value, e.g. - * from AtomicEntryRef to EntryRef. - */ -template <typename MaybeAtomicValue> -class NonAtomicValue { -public: - using type = MaybeAtomicValue; -}; - -template <> -class NonAtomicValue<vespalib::datastore::AtomicEntryRef> -{ -public: - using type = vespalib::datastore::EntryRef; -}; - -template <class MaybeAtomicValue> -using NonAtomicValue_t = typename NonAtomicValue<MaybeAtomicValue>::type; - -} - /** * Helper functions used to open / load attribute vector data files from disk. */ @@ -82,7 +59,7 @@ void loadFromEnumeratedSingleValue(Vector &vector, vespalib::GenerationHolder &genHolder, ReaderBase &attrReader, - vespalib::ConstArrayRef<load_utils::NonAtomicValue_t<typename Vector::ValueType>> enumValueToValueMap, + vespalib::ConstArrayRef<atomic_utils::NonAtomicValue_t<typename Vector::ValueType>> enumValueToValueMap, vespalib::ConstArrayRef<uint32_t> enum_value_remapping, Saver saver) __attribute((noinline)); diff --git a/searchlib/src/vespa/searchlib/attribute/load_utils.hpp b/searchlib/src/vespa/searchlib/attribute/load_utils.hpp index 92cbc72ae2c..74126299919 100644 --- a/searchlib/src/vespa/searchlib/attribute/load_utils.hpp +++ b/searchlib/src/vespa/searchlib/attribute/load_utils.hpp @@ -54,12 +54,12 @@ void loadFromEnumeratedSingleValue(Vector &vector, vespalib::GenerationHolder &genHolder, ReaderBase &attrReader, - vespalib::ConstArrayRef<load_utils::NonAtomicValue_t<typename Vector::ValueType>> enumValueToValueMap, + vespalib::ConstArrayRef<atomic_utils::NonAtomicValue_t<typename Vector::ValueType>> enumValueToValueMap, vespalib::ConstArrayRef<uint32_t> enum_value_remapping, Saver saver) { using ValueType = typename Vector::ValueType; - using NonAtomicValueType = load_utils::NonAtomicValue_t<ValueType>; + using NonAtomicValueType = atomic_utils::NonAtomicValue_t<ValueType>; uint32_t numDocs = attrReader.getEnumCount(); genHolder.clearHoldLists(); vector.reset(); |