summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-09-09 13:01:34 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-09-09 13:02:17 +0000
commit60b59ca7215295d2349c0c0a9843fc4c4d559803 (patch)
tree94b44bd8c0fb6641e1c784f4706ec0bfaab8a762 /searchlib
parentf6af721145f1609bca2274970acbf314983fdc10 (diff)
Remove wrapping of entry type in enum store.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/comparator/comparator_test.cpp6
-rw-r--r--searchlib/src/tests/attribute/enumstore/enumstore_test.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumattribute.h7
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.h1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.cpp24
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.h98
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumstore.hpp18
-rw-r--r--searchlib/src/vespa/searchlib/attribute/floatbase.h21
-rw-r--r--searchlib/src/vespa/searchlib/attribute/integerbase.h20
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp32
-rw-r--r--searchlib/src/vespa/searchlib/attribute/stringbase.h17
12 files changed, 111 insertions, 146 deletions
diff --git a/searchlib/src/tests/attribute/comparator/comparator_test.cpp b/searchlib/src/tests/attribute/comparator/comparator_test.cpp
index 0b709d44900..d935aaa30d2 100644
--- a/searchlib/src/tests/attribute/comparator/comparator_test.cpp
+++ b/searchlib/src/tests/attribute/comparator/comparator_test.cpp
@@ -15,9 +15,9 @@ namespace search {
using namespace btree;
-using NumericEnumStore = EnumStoreT<NumericEntryType<int32_t> >;
-using FloatEnumStore = EnumStoreT<NumericEntryType<float> >;
-using StringEnumStore = EnumStoreT<StringEntryType>;
+using NumericEnumStore = EnumStoreT<int32_t>;
+using FloatEnumStore = EnumStoreT<float>;
+using StringEnumStore = EnumStoreT<const char*>;
using EnumIndex = IEnumStore::Index;
diff --git a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
index 4d1d0b6fff5..ca40b5cc259 100644
--- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
+++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp
@@ -15,15 +15,15 @@ size_t enumStoreAlign(size_t size)
return (size + 15) & -UINT64_C(16);
}
-using NumericEnumStore = EnumStoreT<NumericEntryType<uint32_t> >;
+using NumericEnumStore = EnumStoreT<int32_t>;
using generation_t = vespalib::GenerationHandler::generation_t;
class EnumStoreTest : public vespalib::TestApp
{
private:
- typedef EnumStoreT<StringEntryType> StringEnumStore;
- typedef EnumStoreT<NumericEntryType<float> > FloatEnumStore;
- typedef EnumStoreT<NumericEntryType<double> > DoubleEnumStore;
+ typedef EnumStoreT<const char*> StringEnumStore;
+ typedef EnumStoreT<float> FloatEnumStore;
+ typedef EnumStoreT<double> DoubleEnumStore;
typedef IEnumStore::Index EnumIndex;
@@ -193,7 +193,7 @@ EnumStoreTest::testAddEnum(bool hasPostings)
EXPECT_TRUE(ses.findIndex(unique[i].c_str(), idx));
EXPECT_TRUE(idx == indices[i]);
EXPECT_EQUAL(1u, ses.getRefCount(indices[i]));
- StringEntryType::Type value = 0;
+ const char* value = nullptr;
EXPECT_TRUE(ses.getValue(indices[i], value));
EXPECT_TRUE(strcmp(unique[i].c_str(), value) == 0);
}
@@ -339,7 +339,7 @@ EnumStoreTest::checkReaders(const StringEnumStore & ses,
{
(void) sesGen;
//uint32_t refCount = 1000;
- StringEnumStore::DataType t = "";
+ const char* t = "";
for (uint32_t i = 0; i < readers.size(); ++i) {
const Reader & r = readers[i];
for (uint32_t j = 0; j < r._indices.size(); ++j) {
diff --git a/searchlib/src/vespa/searchlib/attribute/enumattribute.h b/searchlib/src/vespa/searchlib/attribute/enumattribute.h
index 2af698d8552..8c9c949c504 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumattribute.h
@@ -31,7 +31,6 @@ protected:
using EnumEntryType = typename B::EnumEntryType; // Template argument for enum store
using EnumHandle = typename B::EnumHandle;
using EnumModifier = typename B::EnumModifier;
- using EnumType = typename B::EnumEntryType::Type; // Type stored in enum store (integer, float, string)
using ValueModifier = typename B::ValueModifier;
public:
@@ -62,13 +61,13 @@ protected:
const IEnumStore* getEnumStoreBase() const override { return &_enumStore; }
IEnumStore* getEnumStoreBase() override { return &_enumStore; }
- EnumType getFromEnum(EnumHandle e) const override { return _enumStore.getValue(e); }
+ EnumEntryType getFromEnum(EnumHandle e) const override { return _enumStore.getValue(e); }
void load_posting_lists(LoadedVector& loaded) override { (void) loaded; }
void load_enum_store(LoadedVector& loaded) override;
uint64_t getUniqueValueCount() const override;
- static EnumType getDefaultEnumTypeValue() { return B::defaultValue(); }
+ static EnumEntryType getDefaultEnumTypeValue() { return B::defaultValue(); }
/*
* Iterate through the change vector and find new unique values.
@@ -81,7 +80,7 @@ protected:
public:
EnumAttribute(const vespalib::string & baseFileName, const AttributeVector::Config & cfg);
~EnumAttribute();
- bool findEnum(EnumType v, EnumHandle & e) const override { return _enumStore.findEnum(v, e); }
+ bool findEnum(EnumEntryType v, EnumHandle & e) const override { return _enumStore.findEnum(v, e); }
};
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
index 817a3037a9a..67c9a7dc585 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
@@ -83,7 +83,6 @@ EnumStoreFoldedStringComparator::compare_folded_prefix(const char* lhs,
template class EnumStoreComparator<int8_t>;
template class EnumStoreComparator<int16_t>;
template class EnumStoreComparator<int32_t>;
-template class EnumStoreComparator<uint32_t>;
template class EnumStoreComparator<int64_t>;
template class EnumStoreComparator<float>;
template class EnumStoreComparator<double>;
diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.h b/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
index 9a691e3b4e4..a86534d7843 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
@@ -106,7 +106,6 @@ public:
extern template class EnumStoreComparator<int8_t>;
extern template class EnumStoreComparator<int16_t>;
extern template class EnumStoreComparator<int32_t>;
-extern template class EnumStoreComparator<uint32_t>;
extern template class EnumStoreComparator<int64_t>;
extern template class EnumStoreComparator<float>;
extern template class EnumStoreComparator<double>;
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.cpp b/searchlib/src/vespa/searchlib/attribute/enumstore.cpp
index a0f9df3979a..188a381682f 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.cpp
@@ -11,8 +11,8 @@ namespace search {
template <>
void
-EnumStoreT<StringEntryType>::writeValues(BufferWriter& writer,
- vespalib::ConstArrayRef<Index> idxs) const
+EnumStoreT<const char*>::writeValues(BufferWriter& writer,
+ vespalib::ConstArrayRef<Index> idxs) const
{
for (const auto& idx : idxs) {
const char* src = _store.get(idx);
@@ -23,9 +23,9 @@ EnumStoreT<StringEntryType>::writeValues(BufferWriter& writer,
template <>
ssize_t
-EnumStoreT<StringEntryType>::load_unique_value(const void* src,
- size_t available,
- Index& idx)
+EnumStoreT<const char*>::load_unique_value(const void* src,
+ size_t available,
+ Index& idx)
{
const char* value = static_cast<const char*>(src);
size_t slen = strlen(value);
@@ -68,13 +68,13 @@ template
class btree::BTreeBuilder<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
-template class EnumStoreT< StringEntryType >;
-template class EnumStoreT<NumericEntryType<int8_t> >;
-template class EnumStoreT<NumericEntryType<int16_t> >;
-template class EnumStoreT<NumericEntryType<int32_t> >;
-template class EnumStoreT<NumericEntryType<int64_t> >;
-template class EnumStoreT<NumericEntryType<float> >;
-template class EnumStoreT<NumericEntryType<double> >;
+template class EnumStoreT<const char*>;
+template class EnumStoreT<int8_t>;
+template class EnumStoreT<int16_t>;
+template class EnumStoreT<int32_t>;
+template class EnumStoreT<int64_t>;
+template class EnumStoreT<float>;
+template class EnumStoreT<double>;
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h
index 2b1413e26c9..7c651cbc3b3 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h
@@ -23,49 +23,27 @@
namespace search {
/**
- * Class representing a numeric entry type in a enum store.
- * Used as template argument for EnumStoreT.
- **/
-
-template <typename T>
-class NumericEntryType {
-public:
- typedef T Type;
- static uint32_t size(Type) { return fixedSize(); }
- static uint32_t fixedSize() { return sizeof(T); }
- static bool hasFold() { return false; }
-};
-
-/**
- * Class representing a string entry type in a enum store.
- * Used as template argument for EnumStoreT.
- **/
-class StringEntryType {
-public:
- typedef const char * Type;
- static uint32_t size(Type value) { return strlen(value) + fixedSize(); }
- static uint32_t fixedSize() { return 1; }
- static bool hasFold() { return true; }
-};
-
-
-//-----------------------------------------------------------------------------
-// EnumStoreT
-//-----------------------------------------------------------------------------
+ * Class storing and providing access to all unique values stored in an enumerated attribute vector.
+ *
+ * It uses an instance of datastore::UniqueStore to store the actual values.
+ * It also exposes the dictionary used for fast lookups into the set of unique values.
+ *
+ * @tparam EntryType The type of the entries/values stored.
+ * It has special handling of type 'const char *' for strings.
+ */
template <class EntryType>
class EnumStoreT : public IEnumStore
{
friend class EnumStoreTest;
public:
- using DataType = typename EntryType::Type;
- using ComparatorType = std::conditional_t<std::is_same_v<DataType, const char *>,
+ using ComparatorType = std::conditional_t<std::is_same_v<EntryType, const char *>,
EnumStoreStringComparator,
- EnumStoreComparator<DataType>>;
- using AllocatorType = std::conditional_t<std::is_same_v<DataType, const char *>,
+ EnumStoreComparator<EntryType>>;
+ using AllocatorType = std::conditional_t<std::is_same_v<EntryType, const char *>,
datastore::UniqueStoreStringAllocator<InternalIndex>,
- datastore::UniqueStoreAllocator<DataType, InternalIndex>>;
- using UniqueStoreType = datastore::UniqueStore<DataType, InternalIndex, ComparatorType, AllocatorType>;
- using FoldedComparatorType = std::conditional_t<std::is_same_v<DataType, const char *>,
+ datastore::UniqueStoreAllocator<EntryType, InternalIndex>>;
+ using UniqueStoreType = datastore::UniqueStore<EntryType, InternalIndex, ComparatorType, AllocatorType>;
+ using FoldedComparatorType = std::conditional_t<std::is_same_v<EntryType, const char *>,
EnumStoreFoldedStringComparator,
ComparatorType>;
using EnumStoreType = EnumStoreT<EntryType>;
@@ -88,7 +66,7 @@ private:
}
static bool has_string_type() {
- return std::is_same_v<DataType, const char *>;
+ return std::is_same_v<EntryType, const char *>;
}
ssize_t load_unique_values_internal(const void* src, size_t available, IndexVector& idx);
@@ -136,9 +114,9 @@ public:
const datastore::DataStoreBase &get_data_store_base() const override { return _store.get_allocator().get_data_store(); }
- bool getValue(Index idx, DataType& value) const;
- DataType getValue(uint32_t idx) const { return getValue(Index(EntryRef(idx))); }
- DataType getValue(Index idx) const { return _store.get(idx); }
+ bool getValue(Index idx, EntryType& value) const;
+ EntryType getValue(uint32_t idx) const { return getValue(Index(EntryRef(idx))); }
+ EntryType getValue(Index idx) const { return _store.get(idx); }
/**
* Helper class used to load an enum store from non-enumerated save files.
@@ -159,7 +137,7 @@ public:
{
}
~NonEnumeratedLoader();
- Index insert(const DataType& value, uint32_t posting_idx) {
+ Index insert(const EntryType& value, uint32_t posting_idx) {
EntryRef new_ref = _allocator.allocate(value);
_refs.emplace_back(new_ref);
_payloads.emplace_back(posting_idx);
@@ -188,7 +166,7 @@ public:
: _store(store),
_possibly_unused()
{}
- void insert(DataType value) {
+ void insert(EntryType value) {
Index idx;
_store.addEnum(value, idx);
_possibly_unused.insert(idx);
@@ -216,7 +194,7 @@ public:
return ComparatorType(_store.get_data_store());
}
- ComparatorType make_comparator(const DataType& fallback_value) const {
+ ComparatorType make_comparator(const EntryType& fallback_value) const {
return ComparatorType(_store.get_data_store(), fallback_value);
}
@@ -224,17 +202,17 @@ public:
return FoldedComparatorType(_store.get_data_store());
}
- FoldedComparatorType make_folded_comparator(const DataType& fallback_value, bool prefix = false) const {
+ FoldedComparatorType make_folded_comparator(const EntryType& fallback_value, bool prefix = false) const {
return FoldedComparatorType(_store.get_data_store(), fallback_value, prefix);
}
// TODO: Change to sending enum indexes as const array ref.
void writeValues(BufferWriter& writer, vespalib::ConstArrayRef<Index> idxs) const override;
bool foldedChange(const Index &idx1, const Index &idx2) const override;
- bool findEnum(DataType value, IEnumStore::EnumHandle &e) const;
- std::vector<IEnumStore::EnumHandle> findFoldedEnums(DataType value) const;
- void addEnum(DataType value, Index &newIdx);
- bool findIndex(DataType value, Index &idx) const;
+ bool findEnum(EntryType value, IEnumStore::EnumHandle &e) const;
+ std::vector<IEnumStore::EnumHandle> findFoldedEnums(EntryType value) const;
+ void addEnum(EntryType value, Index &newIdx);
+ bool findIndex(EntryType value, Index &idx) const;
void freeUnusedEnums() override;
void freeUnusedEnums(const IndexSet& toRemove);
vespalib::MemoryUsage update_stat() override;
@@ -252,14 +230,14 @@ class datastore::DataStoreT<IEnumStore::Index>;
template <>
void
-EnumStoreT<StringEntryType>::writeValues(BufferWriter& writer,
- vespalib::ConstArrayRef<IEnumStore::Index> idxs) const;
+EnumStoreT<const char*>::writeValues(BufferWriter& writer,
+ vespalib::ConstArrayRef<IEnumStore::Index> idxs) const;
template <>
ssize_t
-EnumStoreT<StringEntryType>::load_unique_value(const void* src,
- size_t available,
- Index& idx);
+EnumStoreT<const char*>::load_unique_value(const void* src,
+ size_t available,
+ Index& idx);
extern template
@@ -269,13 +247,13 @@ extern template
class btree::BTreeBuilder<IEnumStore::Index, datastore::EntryRef, btree::NoAggregated,
EnumTreeTraits::INTERNAL_SLOTS, EnumTreeTraits::LEAF_SLOTS>;
-extern template class EnumStoreT< StringEntryType >;
-extern template class EnumStoreT<NumericEntryType<int8_t> >;
-extern template class EnumStoreT<NumericEntryType<int16_t> >;
-extern template class EnumStoreT<NumericEntryType<int32_t> >;
-extern template class EnumStoreT<NumericEntryType<int64_t> >;
-extern template class EnumStoreT<NumericEntryType<float> >;
-extern template class EnumStoreT<NumericEntryType<double> >;
+extern template class EnumStoreT<const char*>;
+extern template class EnumStoreT<int8_t>;
+extern template class EnumStoreT<int16_t>;
+extern template class EnumStoreT<int32_t>;
+extern template class EnumStoreT<int64_t>;
+extern template class EnumStoreT<float>;
+extern template class EnumStoreT<double>;
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
index dc66adab5ce..2660ad94e68 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp
@@ -57,10 +57,10 @@ template <class EntryType>
ssize_t
EnumStoreT<EntryType>::load_unique_value(const void* src, size_t available, Index& idx)
{
- if (available < sizeof(DataType)) {
+ if (available < sizeof(EntryType)) {
return -1;
}
- const auto* value = static_cast<const DataType*>(src);
+ const auto* value = static_cast<const EntryType*>(src);
Index prev_idx = idx;
idx = _store.get_allocator().allocate(*value);
@@ -68,7 +68,7 @@ EnumStoreT<EntryType>::load_unique_value(const void* src, size_t available, Inde
auto cmp = make_comparator(*value);
assert(cmp(prev_idx, Index()));
}
- return sizeof(DataType);
+ return sizeof(EntryType);
}
template <typename EntryType>
@@ -121,7 +121,7 @@ EnumStoreT<EntryType>::load_unique_values(const void* src, size_t available, Ind
template <typename EntryType>
bool
-EnumStoreT<EntryType>::getValue(Index idx, DataType& value) const
+EnumStoreT<EntryType>::getValue(Index idx, EntryType& value) const
{
if (!idx.valid()) {
return false;
@@ -138,7 +138,7 @@ void
EnumStoreT<EntryType>::writeValues(BufferWriter& writer, vespalib::ConstArrayRef<Index> idxs) const
{
for (const auto& idx : idxs) {
- writer.write(&_store.get(idx), sizeof(DataType));
+ writer.write(&_store.get(idx), sizeof(EntryType));
}
}
@@ -153,7 +153,7 @@ EnumStoreT<EntryType>::foldedChange(const Index &idx1, const Index &idx2) const
template <typename EntryType>
bool
-EnumStoreT<EntryType>::findEnum(DataType value, IEnumStore::EnumHandle &e) const
+EnumStoreT<EntryType>::findEnum(EntryType value, IEnumStore::EnumHandle &e) const
{
auto cmp = make_comparator(value);
Index idx;
@@ -166,7 +166,7 @@ EnumStoreT<EntryType>::findEnum(DataType value, IEnumStore::EnumHandle &e) const
template <typename EntryType>
std::vector<IEnumStore::EnumHandle>
-EnumStoreT<EntryType>::findFoldedEnums(DataType value) const
+EnumStoreT<EntryType>::findFoldedEnums(EntryType value) const
{
auto cmp = make_folded_comparator(value);
return _dict.findMatchingEnums(cmp);
@@ -174,7 +174,7 @@ EnumStoreT<EntryType>::findFoldedEnums(DataType value) const
template <typename EntryType>
bool
-EnumStoreT<EntryType>::findIndex(DataType value, Index &idx) const
+EnumStoreT<EntryType>::findIndex(EntryType value, Index &idx) const
{
auto cmp = make_comparator(value);
return _dict.findIndex(cmp, idx);
@@ -198,7 +198,7 @@ EnumStoreT<EntryType>::freeUnusedEnums(const IndexSet& toRemove)
template <typename EntryType>
void
-EnumStoreT<EntryType>::addEnum(DataType value, Index& newIdx)
+EnumStoreT<EntryType>::addEnum(EntryType value, Index& newIdx)
{
auto cmp = make_comparator(value);
auto add_result = _dict.add(cmp, [this, &value]() -> EntryRef { return _store.get_allocator().allocate(value); });
diff --git a/searchlib/src/vespa/searchlib/attribute/floatbase.h b/searchlib/src/vespa/searchlib/attribute/floatbase.h
index 52f38923f25..ce8d22c2706 100644
--- a/searchlib/src/vespa/searchlib/attribute/floatbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/floatbase.h
@@ -8,10 +8,6 @@
namespace search {
-// forward declaration of class in enumstore.h
-template <typename T>
-class NumericEntryType;
-
class FloatingPointAttribute : public NumericAttribute
{
public:
@@ -36,8 +32,8 @@ public:
protected:
const char * getString(DocId doc, char * s, size_t sz) const override;
FloatingPointAttribute(const vespalib::string & name, const Config & c);
- typedef ChangeTemplate<NumericChangeData<double> > Change;
- typedef ChangeVectorT< Change > ChangeVector;
+ using Change = ChangeTemplate<NumericChangeData<double>>;
+ using ChangeVector = ChangeVectorT<Change>;
ChangeVector _changes;
virtual vespalib::MemoryUsage getChangeVectorMemoryUsage() const override;
@@ -53,18 +49,17 @@ template<typename T>
class FloatingPointAttributeTemplate : public FloatingPointAttribute
{
public:
- typedef WeightedType<T> Weighted;
+ using Weighted = WeightedType<T>;
virtual uint32_t getAll(DocId doc, T * v, uint32_t sz) const = 0;
virtual uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const = 0;
protected:
- typedef NumericEntryType<T> EnumEntryType;
-
- typedef attribute::LoadedNumericValue<T> LoadedNumericValueT;
+ using EnumEntryType = T;
+ using LoadedNumericValueT = attribute::LoadedNumericValue<T>;
public:
- typedef T BaseType;
- typedef T LoadedValueType;
- typedef SequentialReadModifyWriteInterface<LoadedNumericValueT> LoadedVector;
+ using BaseType = T;
+ using LoadedValueType = T;
+ using LoadedVector = SequentialReadModifyWriteInterface<LoadedNumericValueT>;
virtual uint32_t getRawValues(DocId doc, const multivalue::Value<T> * & values) const;
virtual uint32_t getRawValues(DocId doc, const multivalue::WeightedValue<T> * & values) const;
virtual T get(DocId doc) const = 0;
diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.h b/searchlib/src/vespa/searchlib/attribute/integerbase.h
index 05d5b62f8e5..46774f9cebf 100644
--- a/searchlib/src/vespa/searchlib/attribute/integerbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/integerbase.h
@@ -8,10 +8,6 @@
namespace search {
-// forward declaration of class in enumstore.h
-template <typename T>
-class NumericEntryType;
-
class IntegerAttribute : public NumericAttribute
{
public:
@@ -35,8 +31,8 @@ public:
uint32_t clearDoc(DocId doc) override;
protected:
IntegerAttribute(const vespalib::string & name, const Config & c);
- typedef ChangeTemplate<NumericChangeData<largeint_t> > Change;
- typedef ChangeVectorT< Change > ChangeVector;
+ using Change = ChangeTemplate<NumericChangeData<largeint_t>>;
+ using ChangeVector = ChangeVectorT<Change>;
ChangeVector _changes;
vespalib::MemoryUsage getChangeVectorMemoryUsage() const override;
@@ -53,16 +49,16 @@ template<typename T>
class IntegerAttributeTemplate : public IntegerAttribute
{
public:
- typedef WeightedType<T> Weighted;
+ using Weighted = WeightedType<T>;
virtual uint32_t getAll(DocId doc, T * v, uint32_t sz) const = 0;
virtual uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const = 0;
protected:
- typedef NumericEntryType<T> EnumEntryType;
- typedef attribute::LoadedNumericValue<T> LoadedNumericValueT;
+ using EnumEntryType = T;
+ using LoadedNumericValueT = attribute::LoadedNumericValue<T>;
public:
- typedef T BaseType;
- typedef T LoadedValueType;
- typedef SequentialReadModifyWriteInterface<LoadedNumericValueT> LoadedVector;
+ using BaseType = T;
+ using LoadedValueType = T;
+ using LoadedVector = SequentialReadModifyWriteInterface<LoadedNumericValueT>;
virtual uint32_t getRawValues(DocId doc, const multivalue::Value<T> * & values) const;
virtual uint32_t getRawValues(DocId doc, const multivalue::WeightedValue<T> * & values) const;
virtual T get(DocId doc) const = 0;
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
index 079901053a3..a7d001d9fdb 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistattribute.cpp
@@ -323,85 +323,85 @@ template class
PostingListAttributeSubBase<AttributePosting,
LoadedInt8Vector,
int8_t,
- EnumStoreT<NumericEntryType<int8_t> > >;
+ EnumStoreT<int8_t>>;
template class
PostingListAttributeSubBase<AttributePosting,
LoadedInt16Vector,
int16_t,
- EnumStoreT<NumericEntryType<int16_t> > >;
+ EnumStoreT<int16_t>>;
template class
PostingListAttributeSubBase<AttributePosting,
LoadedInt32Vector,
int32_t,
- EnumStoreT<NumericEntryType<int32_t> > >;
+ EnumStoreT<int32_t>>;
template class
PostingListAttributeSubBase<AttributePosting,
LoadedInt64Vector,
int64_t,
- EnumStoreT<NumericEntryType<int64_t> > >;
+ EnumStoreT<int64_t>>;
template class
PostingListAttributeSubBase<AttributePosting,
LoadedFloatVector,
float,
- EnumStoreT<NumericEntryType<float> > >;
+ EnumStoreT<float>>;
template class
PostingListAttributeSubBase<AttributePosting,
LoadedDoubleVector,
double,
- EnumStoreT<NumericEntryType<double> > >;
+ EnumStoreT<double>>;
template class
PostingListAttributeSubBase<AttributePosting,
NoLoadedVector,
- const char *,
- EnumStoreT<StringEntryType > >;
+ const char*,
+ EnumStoreT<const char*>>;
template class
PostingListAttributeSubBase<AttributeWeightPosting,
LoadedInt8Vector,
int8_t,
- EnumStoreT<NumericEntryType<int8_t> > >;
+ EnumStoreT<int8_t>>;
template class
PostingListAttributeSubBase<AttributeWeightPosting,
LoadedInt16Vector,
int16_t,
- EnumStoreT<NumericEntryType<int16_t> > >;
+ EnumStoreT<int16_t>>;
template class
PostingListAttributeSubBase<AttributeWeightPosting,
LoadedInt32Vector,
int32_t,
- EnumStoreT<NumericEntryType<int32_t> > >;
+ EnumStoreT<int32_t>>;
template class
PostingListAttributeSubBase<AttributeWeightPosting,
LoadedInt64Vector,
int64_t,
- EnumStoreT<NumericEntryType<int64_t> > >;
+ EnumStoreT<int64_t>>;
template class
PostingListAttributeSubBase<AttributeWeightPosting,
LoadedFloatVector,
float,
- EnumStoreT<NumericEntryType<float> > >;
+ EnumStoreT<float>>;
template class
PostingListAttributeSubBase<AttributeWeightPosting,
LoadedDoubleVector,
double,
- EnumStoreT<NumericEntryType<double> > >;
+ EnumStoreT<double>>;
template class
PostingListAttributeSubBase<AttributeWeightPosting,
NoLoadedVector,
- const char *,
- EnumStoreT<StringEntryType > >;
+ const char*,
+ EnumStoreT<const char*>>;
}
diff --git a/searchlib/src/vespa/searchlib/attribute/stringbase.h b/searchlib/src/vespa/searchlib/attribute/stringbase.h
index ed19b3aaa05..aec74190465 100644
--- a/searchlib/src/vespa/searchlib/attribute/stringbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/stringbase.h
@@ -15,18 +15,17 @@
namespace search {
-class StringEntryType;
class ReaderBase;
class StringAttribute : public AttributeVector
{
public:
- typedef vespalib::Array<uint32_t> OffsetVector;
- typedef const char * LoadedValueType;
- typedef IEnumStore::Index EnumIndex;
- typedef IEnumStore::IndexVector EnumIndexVector;
- typedef IEnumStore::EnumVector EnumVector;
+ using EnumIndex = IEnumStore::Index;
+ using EnumIndexVector = IEnumStore::IndexVector;
+ using EnumVector = IEnumStore::EnumVector;
+ using LoadedValueType = const char*;
using LoadedVector = NoLoadedVector;
+ using OffsetVector = vespalib::Array<uint32_t>;
public:
DECLARE_IDENTIFIABLE_ABSTRACT(StringAttribute);
bool append(DocId doc, const vespalib::string & v, int32_t weight) {
@@ -61,9 +60,9 @@ protected:
StringAttribute(const vespalib::string & name, const Config & c);
~StringAttribute();
static const char * defaultValue() { return ""; }
- typedef ChangeTemplate<StringChangeData> Change;
- typedef ChangeVectorT< Change > ChangeVector;
- typedef StringEntryType EnumEntryType;
+ using Change = ChangeTemplate<StringChangeData>;
+ using ChangeVector = ChangeVectorT<Change>;
+ using EnumEntryType = const char*;
ChangeVector _changes;
Change _defaultValue;
bool onLoad() override;