summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchlib/src/vespa/searchlib/attribute/floatbase.hpp22
-rw-r--r--searchlib/src/vespa/searchlib/attribute/integerbase.h22
-rw-r--r--searchlib/src/vespa/searchlib/attribute/integerbase.hpp35
3 files changed, 54 insertions, 25 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/floatbase.hpp b/searchlib/src/vespa/searchlib/attribute/floatbase.hpp
index 2b5a949a6ad..93b0d521026 100644
--- a/searchlib/src/vespa/searchlib/attribute/floatbase.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/floatbase.hpp
@@ -6,6 +6,15 @@
namespace search {
+namespace {
+
+template <typename T>
+double createDefaultValue(const attribute::Config & config) {
+ return config.isMutable() ? 0.0 : attribute::getUndefined<T>();
+}
+
+}
+
template<typename T>
uint32_t
FloatingPointAttributeTemplate<T>::getRawValues(DocId, const multivalue::Value<T> * &) const {
@@ -19,21 +28,20 @@ FloatingPointAttributeTemplate<T>::getRawValues(DocId, const multivalue::Weighte
}
template<typename T>
-FloatingPointAttributeTemplate<T>::FloatingPointAttributeTemplate(const vespalib::string & name) :
- FloatingPointAttribute(name, BasicType::fromType(T())),
- _defaultValue(ChangeBase::UPDATE, 0, attribute::getUndefined<T>())
+FloatingPointAttributeTemplate<T>::FloatingPointAttributeTemplate(const vespalib::string & name)
+ : FloatingPointAttributeTemplate(name, BasicType::fromType(T()))
{ }
template<typename T>
-FloatingPointAttributeTemplate<T>::FloatingPointAttributeTemplate(const vespalib::string & name, const Config & c) :
- FloatingPointAttribute(name, c),
- _defaultValue(ChangeBase::UPDATE, 0, attribute::getUndefined<T>())
+FloatingPointAttributeTemplate<T>::FloatingPointAttributeTemplate(const vespalib::string & name, const Config & c)
+ : FloatingPointAttribute(name, c),
+ _defaultValue(ChangeBase::UPDATE, 0, createDefaultValue<T>(c))
{
assert(c.basicType() == BasicType::fromType(T()));
}
template<typename T>
-FloatingPointAttributeTemplate<T>::~FloatingPointAttributeTemplate() { }
+FloatingPointAttributeTemplate<T>::~FloatingPointAttributeTemplate() = default;
template<typename T>
bool
diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.h b/searchlib/src/vespa/searchlib/attribute/integerbase.h
index 5ce9ad11ec8..c791adc8c53 100644
--- a/searchlib/src/vespa/searchlib/attribute/integerbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/integerbase.h
@@ -63,24 +63,10 @@ public:
virtual T get(DocId doc) const = 0;
virtual T getFromEnum(EnumHandle e) const = 0;
protected:
- IntegerAttributeTemplate(const vespalib::string & name) :
- IntegerAttribute(name, BasicType::fromType(T())),
- _defaultValue(ChangeBase::UPDATE, 0, defaultValue())
- { }
- IntegerAttributeTemplate(const vespalib::string & name, const Config & c) :
- IntegerAttribute(name, c),
- _defaultValue(ChangeBase::UPDATE, 0, defaultValue())
- {
- assert(c.basicType() == BasicType::fromType(T()));
- }
- IntegerAttributeTemplate(const vespalib::string & name, const Config & c, const BasicType &realType)
- : IntegerAttribute(name, c),
- _defaultValue(ChangeBase::UPDATE, 0, 0u)
- {
- assert(c.basicType() == realType);
- (void) realType;
- assert(BasicType::fromType(T()) == BasicType::INT8);
- }
+ IntegerAttributeTemplate(const vespalib::string & name);
+ IntegerAttributeTemplate(const vespalib::string & name, const Config & c);
+ IntegerAttributeTemplate(const vespalib::string & name, const Config & c, const BasicType &realType);
+ ~IntegerAttributeTemplate() override;
static T defaultValue() { return attribute::getUndefined<T>(); }
virtual bool findEnum(T v, EnumHandle & e) const = 0;
virtual void load_enum_store(LoadedVector&) {}
diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.hpp b/searchlib/src/vespa/searchlib/attribute/integerbase.hpp
index 6d6c6929f50..2b16a541a54 100644
--- a/searchlib/src/vespa/searchlib/attribute/integerbase.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/integerbase.hpp
@@ -8,6 +8,41 @@ namespace search {
using largeint_t = attribute::IAttributeVector::largeint_t;
+namespace {
+
+template <typename T>
+largeint_t createDefaultValue(const attribute::Config & config) {
+ return config.isMutable() ? 0 : attribute::getUndefined<T>();
+}
+
+}
+
+template<typename T>
+IntegerAttributeTemplate<T>::IntegerAttributeTemplate(const vespalib::string & name)
+ : IntegerAttributeTemplate(name, BasicType::fromType(T()))
+{ }
+
+template<typename T>
+IntegerAttributeTemplate<T>::IntegerAttributeTemplate(const vespalib::string & name, const Config & c)
+ : IntegerAttribute(name, c),
+ _defaultValue(ChangeBase::UPDATE, 0, createDefaultValue<T>(c))
+{
+ assert(c.basicType() == BasicType::fromType(T()));
+}
+
+template<typename T>
+IntegerAttributeTemplate<T>::IntegerAttributeTemplate(const vespalib::string & name, const Config & c, const BasicType &realType)
+ : IntegerAttribute(name, c),
+ _defaultValue(ChangeBase::UPDATE, 0, 0u)
+{
+ assert(c.basicType() == realType);
+ (void) realType;
+ assert(BasicType::fromType(T()) == BasicType::INT8);
+}
+
+template<typename T>
+IntegerAttributeTemplate<T>::~IntegerAttributeTemplate() = default;
+
template<typename T>
uint32_t
IntegerAttributeTemplate<T>::getRawValues(DocId, const multivalue::Value<T> * &) const {