diff options
author | Tor Egge <Tor.Egge@yahooinc.com> | 2022-04-22 12:34:22 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahooinc.com> | 2022-04-22 12:34:22 +0200 |
commit | 022c7b49c92e7910456dd484aee1ccf9ae76f18d (patch) | |
tree | 88a68826a5f5fe57e29bdd826bf4be7625dc769f /searchlib | |
parent | 5e77ba78f83c8f9132f604614b5d7b1714f867a7 (diff) |
Remove getAll() member functions from attribute vectors.
Diffstat (limited to 'searchlib')
10 files changed, 22 insertions, 65 deletions
diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp index 0154e95c155..9c1caaff662 100644 --- a/searchlib/src/tests/sortspec/multilevelsort.cpp +++ b/searchlib/src/tests/sortspec/multilevelsort.cpp @@ -9,6 +9,7 @@ #include <vespa/searchlib/uca/ucaconverter.h> #include <vespa/vespalib/util/testclock.h> #include <vespa/vespalib/testkit/testapp.h> +#include <type_traits> #include <vespa/log/log.h> LOG_SETUP("multilevelsort_test"); @@ -61,8 +62,8 @@ private: template<typename T> void fill(FloatingPointAttribute *attr, uint32_t size, uint32_t unique = 0); void fill(StringAttribute *attr, uint32_t size, const std::vector<std::string> &values); - template<typename T, typename V> - int compareTemplate(T *vector, uint32_t a, uint32_t b); + template <typename V> + int compareTemplate(AttributeVector *vector, uint32_t a, uint32_t b); int compare(AttributeVector *vector, AttrType type, uint32_t a, uint32_t b); void sortAndCheck(const std::vector<Spec> &spec, uint32_t num, uint32_t unique, const std::vector<std::string> &strValues); @@ -138,14 +139,23 @@ MultilevelSortTest::fill(StringAttribute *attr, uint32_t size, const std::vector } } -template<typename T, typename V> +template <typename V> +V get_helper(AttributeVector *vector, uint32_t doc_id) { + if constexpr (std::is_floating_point_v<V>) { + return vector->getFloat(doc_id); + } else { + return vector->getInt(doc_id); + } +} + +template <typename V> int -MultilevelSortTest::compareTemplate(T *vector, uint32_t a, uint32_t b) +MultilevelSortTest::compareTemplate(AttributeVector *vector, uint32_t a, uint32_t b) { V va; V vb; - vector->getAll(a, &va, 1); - vector->getAll(b, &vb, 1); + va = get_helper<V>(vector, a); + vb = get_helper<V>(vector, b); if (va == vb) { return 0; } else if (va < vb) { @@ -158,17 +168,17 @@ int MultilevelSortTest::compare(AttributeVector *vector, AttrType type, uint32_t a, uint32_t b) { if (type == INT8) { - return compareTemplate<Int8, int8_t>(static_cast<Int8*>(vector), a, b); + return compareTemplate<int8_t>(vector, a, b); } else if (type == INT16) { - return compareTemplate<Int16, int16_t>(static_cast<Int16*>(vector), a, b); + return compareTemplate<int16_t>(vector, a, b); } else if (type == INT32) { - return compareTemplate<Int32, int32_t>(static_cast<Int32*>(vector), a, b); + return compareTemplate<int32_t>(vector, a, b); } else if (type == INT64) { - return compareTemplate<Int64, int64_t>(static_cast<Int64*>(vector), a, b); + return compareTemplate<int64_t>(vector, a, b); } else if (type == FLOAT) { - return compareTemplate<Float, float>(static_cast<Float*>(vector), a, b); + return compareTemplate<float>(vector, a, b); } else if (type == DOUBLE) { - return compareTemplate<Double, double>(static_cast<Double*>(vector), a, b); + return compareTemplate<double>(vector, a, b); } else if (type == STRING) { StringAttribute *vString = static_cast<StringAttribute*>(vector); const char *va = vString->get(a); diff --git a/searchlib/src/vespa/searchlib/attribute/attrvector.h b/searchlib/src/vespa/searchlib/attribute/attrvector.h index 7713c210033..d1d2a1e8f3c 100644 --- a/searchlib/src/vespa/searchlib/attribute/attrvector.h +++ b/searchlib/src/vespa/searchlib/attribute/attrvector.h @@ -79,7 +79,6 @@ private: typedef typename B::WeightedFloat WeightedFloat; BaseType get(DocId doc) const override { return getHelper(doc, 0); } EnumHandle getEnum(DocId doc) const override { return getEnumHelper(doc, 0); } - uint32_t getAll(DocId doc, BaseType * v, uint32_t sz) const override { return getAllHelper<BaseType, BaseType>(doc, v, sz); } uint32_t get(DocId doc, EnumHandle * e, uint32_t sz) const override { return getAllEnumHelper(doc, e, sz); } uint32_t getValueCount(DocId doc) const override { return getValueCountHelper(doc); } @@ -125,7 +124,6 @@ private: } uint32_t get(DocId doc, WeightedEnum * v, uint32_t sz) const override { return getAllEnumHelper(doc, v, sz); } - uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const override { return getAllHelper<Weighted, BaseType>(doc, v, sz); } uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override { return getAllHelper<WeightedInt, largeint_t>(doc, v, sz); } uint32_t get(DocId doc, WeightedFloat * v, uint32_t sz) const override { return getAllHelper<WeightedFloat, double>(doc, v, sz); } }; diff --git a/searchlib/src/vespa/searchlib/attribute/floatbase.h b/searchlib/src/vespa/searchlib/attribute/floatbase.h index f10e8189c29..8ca6eda6421 100644 --- a/searchlib/src/vespa/searchlib/attribute/floatbase.h +++ b/searchlib/src/vespa/searchlib/attribute/floatbase.h @@ -50,8 +50,6 @@ class FloatingPointAttributeTemplate : public FloatingPointAttribute { public: 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: using EnumEntryType = T; using LoadedNumericValueT = attribute::LoadedNumericValue<T>; diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.h b/searchlib/src/vespa/searchlib/attribute/integerbase.h index 926ced7c7e0..65d16ce934a 100644 --- a/searchlib/src/vespa/searchlib/attribute/integerbase.h +++ b/searchlib/src/vespa/searchlib/attribute/integerbase.h @@ -49,8 +49,6 @@ class IntegerAttributeTemplate : public IntegerAttribute { public: 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: using EnumEntryType = T; using LoadedNumericValueT = attribute::LoadedNumericValue<T>; diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h index e07498d9ca4..cc128b0eef1 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h @@ -91,9 +91,6 @@ public: (void) doc; return std::numeric_limits<uint32_t>::max(); // does not have enum } - uint32_t getAll(DocId doc, T * v, uint32_t sz) const override { - return getHelper(doc, v, sz); - } uint32_t get(DocId doc, largeint_t * v, uint32_t sz) const override { return getHelper(doc, v, sz); } @@ -125,9 +122,6 @@ public: } return available; } - uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const override{ - return getWeightedHelper<Weighted, T>(doc, v, sz); - } uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override { return getWeightedHelper<WeightedInt, largeint_t>(doc, v, sz); } diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.h index 9f8506d3cb4..30e379d7739 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multinumericenumattribute.h @@ -77,9 +77,6 @@ public: } return valueCount; } - uint32_t getAll(DocId doc, T * v, uint32_t sz) const override { - return getHelper(doc, v, sz); - } uint32_t get(DocId doc, largeint_t * v, uint32_t sz) const override { return getHelper(doc, v, sz); } @@ -96,9 +93,6 @@ public: } return valueCount; } - uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const override { - return getWeightedHelper<Weighted, T>(doc, v, sz); - } uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override { return getWeightedHelper<WeightedInt, largeint_t>(doc, v, sz); } diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h index f7efe27277e..77c8b7e318f 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h @@ -45,12 +45,6 @@ public: uint32_t getEnum(DocId) const override { return std::numeric_limits<uint32_t>::max(); // does not have enum } - uint32_t getAll(DocId doc, int8_t * v, uint32_t sz) const override { - if (sz > 0) { - v[0] = getFast(doc); - } - return 1; - } uint32_t get(DocId doc, largeint_t * v, uint32_t sz) const override { if (sz > 0) { v[0] = static_cast<largeint_t>(getFast(doc)); @@ -69,7 +63,6 @@ public: } return 1; } - uint32_t getAll(DocId, Weighted *, uint32_t) const override { return 0; } uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override { if (sz > 0) { v[0] = WeightedInt(static_cast<largeint_t>(getFast(doc))); diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h index 71a5f4f738e..cf3fa85a060 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h @@ -93,11 +93,6 @@ public: (void) doc; return std::numeric_limits<uint32_t>::max(); // does not have enum } - uint32_t getAll(DocId doc, T * v, uint32_t sz) const override { - (void) sz; - v[0] = getFast(doc); - return 1; - } uint32_t get(DocId doc, largeint_t * v, uint32_t sz) const override { (void) sz; v[0] = static_cast<largeint_t>(getFast(doc)); @@ -113,10 +108,6 @@ public: e[0] = getEnum(doc); return 1; } - uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const override { - (void) doc; (void) v; (void) sz; - return 0; - } uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override { (void) sz; v[0] = WeightedInt(static_cast<largeint_t>(getFast(doc))); diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h index a269aec5c6b..5b0e1c6131e 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericenumattribute.h @@ -74,12 +74,6 @@ public: double getFloat(DocId doc) const override { return static_cast<double>(get(doc)); } - uint32_t getAll(DocId doc, T * v, uint32_t sz) const override { - if (sz > 0) { - v[0] = get(doc); - } - return 1; - } uint32_t get(DocId doc, largeint_t * v, uint32_t sz) const override { if (sz > 0) { v[0] = getInt(doc); @@ -92,12 +86,6 @@ public: } return 1; } - uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const override { - if (sz > 0) { - v[0] = Weighted(get(doc)); - } - return 1; - } uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override { if (sz > 0) { v[0] = WeightedInt(getInt(doc)); diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h index f6059d3d510..646edc786a3 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h @@ -100,12 +100,6 @@ public: uint32_t getEnum(DocId) const override { return std::numeric_limits<uint32_t>::max(); // does not have enum } - uint32_t getAll(DocId doc, T * v, uint32_t sz) const override { - if (sz > 0) { - v[0] = getFast(doc); - } - return 1; - } uint32_t get(DocId doc, largeint_t * v, uint32_t sz) const override { if (sz > 0) { v[0] = static_cast<largeint_t>(getFast(doc)); @@ -124,7 +118,6 @@ public: } return 1; } - uint32_t getAll(DocId, Weighted *, uint32_t) const override { return 0; } uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override { if (sz > 0) { v[0] = WeightedInt(static_cast<largeint_t>(getFast(doc))); |