diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-11-08 14:57:40 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-11-08 15:00:32 +0000 |
commit | 7aa695db569e2821b50f1af373bc589c734ee1e7 (patch) | |
tree | dd98abc7aca57e9074821661a3a98dbdbe051010 /searchcommon/src | |
parent | 81f33dd36a90bcef7be8a88021a820526b093c06 (diff) |
- Move utility methods from proton::attribute to search::attribute.
- Compute isUpdateableInmemoryOnly once.
Diffstat (limited to 'searchcommon/src')
4 files changed, 55 insertions, 1 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/CMakeLists.txt b/searchcommon/src/vespa/searchcommon/attribute/CMakeLists.txt index 8ceb3c76438..0ab126147a6 100644 --- a/searchcommon/src/vespa/searchcommon/attribute/CMakeLists.txt +++ b/searchcommon/src/vespa/searchcommon/attribute/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_library(searchcommon_searchcommon_attribute OBJECT SOURCES + attribute_utils.cpp basictype.cpp collectiontype.cpp config.cpp diff --git a/searchcommon/src/vespa/searchcommon/attribute/attribute_utils.cpp b/searchcommon/src/vespa/searchcommon/attribute/attribute_utils.cpp new file mode 100644 index 00000000000..7c15d7bbc14 --- /dev/null +++ b/searchcommon/src/vespa/searchcommon/attribute/attribute_utils.cpp @@ -0,0 +1,23 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "attribute_utils.h" +#include <vespa/searchcommon/attribute/config.h> + +namespace search::attribute { + +bool +isUpdateableInMemoryOnly(const vespalib::string &attrName, const Config &cfg) +{ + auto basicType = cfg.basicType().type(); + return ((basicType != BasicType::Type::PREDICATE) && + (basicType != BasicType::Type::REFERENCE)) && + !isStructFieldAttribute(attrName); +} + +bool +isStructFieldAttribute(const vespalib::string &attrName) +{ + return attrName.find('.') != vespalib::string::npos; +} + +} diff --git a/searchcommon/src/vespa/searchcommon/attribute/attribute_utils.h b/searchcommon/src/vespa/searchcommon/attribute/attribute_utils.h new file mode 100644 index 00000000000..f87da30942d --- /dev/null +++ b/searchcommon/src/vespa/searchcommon/attribute/attribute_utils.h @@ -0,0 +1,30 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/vespalib/stllike/string.h> + +namespace search::attribute { + +class Config; + +/** + * Returns whether the given attribute vector is updateable only in-memory. + * + * For most attributes this is true. + * The data stored in the attribute is equal to the data stored in the field value in the document. + * + * For predicate and reference attributes this is false. + * The original data is transformed (lossy) before it is stored in the attribute. + * During update we also need to update the field value in the document. + * + * For struct field attributes this is false. + * A struct field attribute typically represents a sub-field of a more complex field (e.g. map of struct or array of struct). + * During update the complex field is first updated in the document, + * then the struct field attribute is updated based on the new content of the complex field. + */ +bool isUpdateableInMemoryOnly(const vespalib::string &attrName, const Config &cfg); + +bool isStructFieldAttribute(const vespalib::string &attrName); + +} diff --git a/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h b/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h index c26906ac7c0..cc01d1d95e1 100644 --- a/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h +++ b/searchcommon/src/vespa/searchcommon/attribute/iattributevector.h @@ -431,7 +431,7 @@ public: /** * Virtual destructor to allow safe subclassing. **/ - virtual ~IAttributeVector() {} + virtual ~IAttributeVector() = default; /** * This method is used to simulate sparseness in the single value attributes. |