aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-07-28 10:40:36 +0800
committerGitHub <noreply@github.com>2023-07-28 10:40:36 +0800
commitfbfca70e193c80417ea7a5ab3d92cd44c60507f4 (patch)
tree577cfc65f8b698cf9fd06c594347f5b9217953e5 /searchlib
parent61e51083f405836b0daaebe9606a7c052f6d63ff (diff)
parent8d391112a29c147941ea392dc550b9ff7841419b (diff)
Merge pull request #27913 from vespa-engine/balder/add-noexcept
Add noexcept
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchcommon/common/schema.cpp30
-rw-r--r--searchlib/src/vespa/searchcommon/common/schema.h113
-rw-r--r--searchlib/src/vespa/searchlib/fef/itermfielddata.h14
-rw-r--r--searchlib/src/vespa/searchlib/fef/simpletermfielddata.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/fef/simpletermfielddata.h12
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.cpp2
6 files changed, 75 insertions, 108 deletions
diff --git a/searchlib/src/vespa/searchcommon/common/schema.cpp b/searchlib/src/vespa/searchcommon/common/schema.cpp
index 7a3e15dbd6d..41a1803408f 100644
--- a/searchlib/src/vespa/searchcommon/common/schema.cpp
+++ b/searchlib/src/vespa/searchcommon/common/schema.cpp
@@ -57,7 +57,7 @@ struct FieldName {
template <typename T>
uint32_t
-getFieldId(vespalib::stringref name, const T &map)
+getFieldId(vespalib::stringref name, const T &map) noexcept
{
auto it = map.find(name);
return (it != map.end()) ? it->second : Schema::UNKNOWN_FIELD_ID;
@@ -111,7 +111,7 @@ Schema::Field::write(vespalib::asciistream & os, vespalib::stringref prefix) con
}
bool
-Schema::Field::operator==(const Field &rhs) const
+Schema::Field::operator==(const Field &rhs) const noexcept
{
return _name == rhs._name &&
_dataType == rhs._dataType &&
@@ -120,7 +120,7 @@ Schema::Field::operator==(const Field &rhs) const
}
bool
-Schema::Field::operator!=(const Field &rhs) const
+Schema::Field::operator!=(const Field &rhs) const noexcept
{
return !((*this) == rhs);
}
@@ -166,7 +166,7 @@ Schema::IndexField::write(vespalib::asciistream & os, vespalib::stringref prefix
}
bool
-Schema::IndexField::operator==(const IndexField &rhs) const
+Schema::IndexField::operator==(const IndexField &rhs) const noexcept
{
return Field::operator==(rhs) &&
_avgElemLen == rhs._avgElemLen &&
@@ -174,7 +174,7 @@ Schema::IndexField::operator==(const IndexField &rhs) const
}
bool
-Schema::IndexField::operator!=(const IndexField &rhs) const
+Schema::IndexField::operator!=(const IndexField &rhs) const noexcept
{
return Field::operator!=(rhs) ||
_avgElemLen != rhs._avgElemLen ||
@@ -197,14 +197,14 @@ Schema::FieldSet & Schema::FieldSet::operator = (const FieldSet &) = default;
Schema::FieldSet::~FieldSet() = default;
bool
-Schema::FieldSet::operator==(const FieldSet &rhs) const
+Schema::FieldSet::operator==(const FieldSet &rhs) const noexcept
{
return _name == rhs._name &&
_fields == rhs._fields;
}
bool
-Schema::FieldSet::operator!=(const FieldSet &rhs) const
+Schema::FieldSet::operator!=(const FieldSet &rhs) const noexcept
{
return _name != rhs._name ||
_fields != rhs._fields;
@@ -364,31 +364,31 @@ Schema::addFieldSet(const FieldSet &fieldSet)
}
uint32_t
-Schema::getIndexFieldId(vespalib::stringref name) const
+Schema::getIndexFieldId(vespalib::stringref name) const noexcept
{
return getFieldId(name, _indexIds);
}
uint32_t
-Schema::getAttributeFieldId(vespalib::stringref name) const
+Schema::getAttributeFieldId(vespalib::stringref name) const noexcept
{
return getFieldId(name, _attributeIds);
}
uint32_t
-Schema::getFieldSetId(vespalib::stringref name) const
+Schema::getFieldSetId(vespalib::stringref name) const noexcept
{
return getFieldId(name, _fieldSetIds);
}
bool
-Schema::isIndexField(vespalib::stringref name) const
+Schema::isIndexField(vespalib::stringref name) const noexcept
{
return _indexIds.find(name) != _indexIds.end();
}
bool
-Schema::isAttributeField(vespalib::stringref name) const
+Schema::isAttributeField(vespalib::stringref name) const noexcept
{
return _attributeIds.find(name) != _attributeIds.end();
}
@@ -516,7 +516,7 @@ Schema::set_difference(const Schema &lhs, const Schema &rhs)
}
bool
-Schema::operator==(const Schema &rhs) const
+Schema::operator==(const Schema &rhs) const noexcept
{
return _indexFields == rhs._indexFields &&
_attributeFields == rhs._attributeFields &&
@@ -525,7 +525,7 @@ Schema::operator==(const Schema &rhs) const
}
bool
-Schema::operator!=(const Schema &rhs) const
+Schema::operator!=(const Schema &rhs) const noexcept
{
return _indexFields != rhs._indexFields ||
_attributeFields != rhs._attributeFields ||
@@ -534,7 +534,7 @@ Schema::operator!=(const Schema &rhs) const
}
bool
-Schema::empty() const
+Schema::empty() const noexcept
{
return _indexFields.empty() &&
_attributeFields.empty() &&
diff --git a/searchlib/src/vespa/searchcommon/common/schema.h b/searchlib/src/vespa/searchcommon/common/schema.h
index 2e9edaa702e..a2eb1dacd65 100644
--- a/searchlib/src/vespa/searchcommon/common/schema.h
+++ b/searchlib/src/vespa/searchcommon/common/schema.h
@@ -50,22 +50,20 @@ public:
virtual ~Field();
- virtual void
- write(vespalib::asciistream & os,
- vespalib::stringref prefix) const;
+ virtual void write(vespalib::asciistream & os, vespalib::stringref prefix) const;
- const vespalib::string &getName() const { return _name; }
- DataType getDataType() const { return _dataType; }
- CollectionType getCollectionType() const { return _collectionType; }
- const vespalib::string& get_tensor_spec() const { return _tensor_spec; }
+ const vespalib::string &getName() const noexcept { return _name; }
+ DataType getDataType() const noexcept { return _dataType; }
+ CollectionType getCollectionType() const noexcept { return _collectionType; }
+ const vespalib::string& get_tensor_spec() const noexcept { return _tensor_spec; }
- bool matchingTypes(const Field &rhs) const {
+ bool matchingTypes(const Field &rhs) const noexcept {
return getDataType() == rhs.getDataType() &&
getCollectionType() == rhs.getCollectionType();
}
- bool operator==(const Field &rhs) const;
- bool operator!=(const Field &rhs) const;
+ bool operator==(const Field &rhs) const noexcept;
+ bool operator!=(const Field &rhs) const noexcept;
};
@@ -91,8 +89,8 @@ public:
**/
explicit IndexField(const config::StringVector &lines);
- IndexField &setAvgElemLen(uint32_t avgElemLen) { _avgElemLen = avgElemLen; return *this; }
- IndexField &set_interleaved_features(bool value) {
+ IndexField &setAvgElemLen(uint32_t avgElemLen) noexcept { _avgElemLen = avgElemLen; return *this; }
+ IndexField &set_interleaved_features(bool value) noexcept {
_interleaved_features = value;
return *this;
}
@@ -100,11 +98,11 @@ public:
void write(vespalib::asciistream &os,
vespalib::stringref prefix) const override;
- uint32_t getAvgElemLen() const { return _avgElemLen; }
- bool use_interleaved_features() const { return _interleaved_features; }
+ uint32_t getAvgElemLen() const noexcept { return _avgElemLen; }
+ bool use_interleaved_features() const noexcept { return _interleaved_features; }
- bool operator==(const IndexField &rhs) const;
- bool operator!=(const IndexField &rhs) const;
+ bool operator==(const IndexField &rhs) const noexcept;
+ bool operator!=(const IndexField &rhs) const noexcept;
};
using AttributeField = Field;
@@ -120,7 +118,7 @@ public:
std::vector<vespalib::string> _fields;
public:
- explicit FieldSet(vespalib::stringref n) : _name(n), _fields() {}
+ explicit FieldSet(vespalib::stringref n) noexcept : _name(n), _fields() {}
FieldSet(const FieldSet &);
FieldSet & operator =(const FieldSet &);
FieldSet(FieldSet &&) noexcept = default;
@@ -138,13 +136,11 @@ public:
return *this;
}
- const vespalib::string &getName() const { return _name; }
- const std::vector<vespalib::string> &getFields() const {
- return _fields;
- }
+ const vespalib::string &getName() const noexcept { return _name; }
+ const std::vector<vespalib::string> &getFields() const noexcept { return _fields; }
- bool operator==(const FieldSet &rhs) const;
- bool operator!=(const FieldSet &rhs) const;
+ bool operator==(const FieldSet &rhs) const noexcept;
+ bool operator!=(const FieldSet &rhs) const noexcept;
};
static const uint32_t UNKNOWN_FIELD_ID;
@@ -179,8 +175,7 @@ public:
* @param fileName the name of the file.
* @return true if the schema could be loaded.
**/
- bool
- loadFromFile(const vespalib::string & fileName);
+ bool loadFromFile(const vespalib::string & fileName);
/**
* Save this schema to the file with the given name.
@@ -188,8 +183,7 @@ public:
* @param fileName the name of the file.
* @return true if the schema could be saved.
**/
- bool
- saveToFile(const vespalib::string & fileName) const;
+ bool saveToFile(const vespalib::string & fileName) const;
vespalib::string toString() const;
@@ -198,28 +192,24 @@ public:
*
* @param field the field to add
**/
- Schema &
- addIndexField(const IndexField &field);
+ Schema & addIndexField(const IndexField &field);
// Only used by tests.
- Schema &
- addUriIndexFields(const IndexField &field);
+ Schema & addUriIndexFields(const IndexField &field);
/**
* Add an attribute field to this schema
*
* @param field the field to add
**/
- Schema &
- addAttributeField(const AttributeField &field);
+ Schema & addAttributeField(const AttributeField &field);
/**
* Add a field set to this schema.
*
* @param collection the field set to add.
**/
- Schema &
- addFieldSet(const FieldSet &collection);
+ Schema & addFieldSet(const FieldSet &collection);
Schema &addImportedAttributeField(const ImportedAttributeField &field);
@@ -228,23 +218,23 @@ public:
*
* @return number of fields
**/
- uint32_t getNumIndexFields() const { return _indexFields.size(); }
+ uint32_t getNumIndexFields() const noexcept { return _indexFields.size(); }
/**
* Obtain the number of attribute fields in this schema.
*
* @return number of fields
**/
- uint32_t getNumAttributeFields() const { return _attributeFields.size(); }
+ uint32_t getNumAttributeFields() const noexcept { return _attributeFields.size(); }
/**
* Obtain the number of field sets in this schema.
*
* @return number of field sets.
**/
- uint32_t getNumFieldSets() const { return _fieldSets.size(); }
+ uint32_t getNumFieldSets() const noexcept { return _fieldSets.size(); }
- size_t getNumImportedAttributeFields() const { return _importedAttributeFields.size(); }
+ size_t getNumImportedAttributeFields() const noexcept { return _importedAttributeFields.size(); }
/**
* Get information about a specific index field using the given fieldId.
@@ -252,18 +242,12 @@ public:
* @return the field
* @param idx an index in the range [0, size - 1].
**/
- const IndexField &
- getIndexField(uint32_t fieldId) const
- {
- return _indexFields[fieldId];
- }
+ const IndexField & getIndexField(uint32_t fieldId) const noexcept { return _indexFields[fieldId]; }
/**
* Returns const view of the index fields.
*/
- const std::vector<IndexField> &getIndexFields() const {
- return _indexFields;
- }
+ const std::vector<IndexField> &getIndexFields() const noexcept { return _indexFields; }
/**
* Get the field id for the index field with the given name.
@@ -271,7 +255,7 @@ public:
* @return the field id or UNKNOWN_FIELD_ID if not found.
* @param name the name of the field.
**/
- uint32_t getIndexFieldId(vespalib::stringref name) const;
+ uint32_t getIndexFieldId(vespalib::stringref name) const noexcept;
/**
* Check if a field is an index
@@ -279,7 +263,7 @@ public:
* @return true if field is an index field.
* @param name the name of the field.
**/
- bool isIndexField(vespalib::stringref name) const;
+ bool isIndexField(vespalib::stringref name) const noexcept;
/**
* Check if a field is a attribute field
@@ -287,7 +271,7 @@ public:
* @return true if field is an attribute field.
* @param name the name of the field.
**/
- bool isAttributeField(vespalib::stringref name) const;
+ bool isAttributeField(vespalib::stringref name) const noexcept;
/**
* Get information about a specific attribute field using the given fieldId.
@@ -295,18 +279,12 @@ public:
* @return the field
* @param idx an index in the range [0, size - 1].
**/
- const AttributeField &
- getAttributeField(uint32_t fieldId) const
- {
- return _attributeFields[fieldId];
- }
+ const AttributeField & getAttributeField(uint32_t fieldId) const noexcept { return _attributeFields[fieldId]; }
/**
* Returns const view of the attribute fields.
*/
- const std::vector<AttributeField> &getAttributeFields() const {
- return _attributeFields;
- }
+ const std::vector<AttributeField> &getAttributeFields() const noexcept { return _attributeFields; }
/**
* Get the field id for the attribute field with the given name.
@@ -314,7 +292,7 @@ public:
* @return the field id or UNKNOWN_FIELD_ID if not found.
* @param name the name of the field.
**/
- uint32_t getAttributeFieldId(vespalib::stringref name) const;
+ uint32_t getAttributeFieldId(vespalib::stringref name) const noexcept;
/**
* Get information about a specific field set
@@ -322,11 +300,7 @@ public:
* @return the field set.
* @param idx an index in the range [0, size - 1].
**/
- const FieldSet &
- getFieldSet(uint32_t idx) const
- {
- return _fieldSets[idx];
- }
+ const FieldSet & getFieldSet(uint32_t idx) const noexcept { return _fieldSets[idx]; }
/**
* Get the field id for the field set with the given name.
@@ -334,10 +308,9 @@ public:
* @return the field id or UNKNOWN_FIELD_ID if not found.
* @param name the name of the field set.
**/
- uint32_t
- getFieldSetId(vespalib::stringref name) const;
+ uint32_t getFieldSetId(vespalib::stringref name) const noexcept;
- const std::vector<ImportedAttributeField> &getImportedAttributeFields() const {
+ const std::vector<ImportedAttributeField> &getImportedAttributeFields() const noexcept {
return _importedAttributeFields;
}
@@ -348,10 +321,10 @@ public:
static Schema::UP make_union(const Schema &lhs, const Schema &rhs);
static Schema::UP set_difference(const Schema &lhs, const Schema &rhs);
- bool operator==(const Schema &rhs) const;
- bool operator!=(const Schema &rhs) const;
+ bool operator==(const Schema &rhs) const noexcept ;
+ bool operator!=(const Schema &rhs) const noexcept;
- bool empty() const;
+ bool empty() const noexcept;
};
}
diff --git a/searchlib/src/vespa/searchlib/fef/itermfielddata.h b/searchlib/src/vespa/searchlib/fef/itermfielddata.h
index 88fa8c5f781..ca31851e161 100644
--- a/searchlib/src/vespa/searchlib/fef/itermfielddata.h
+++ b/searchlib/src/vespa/searchlib/fef/itermfielddata.h
@@ -17,7 +17,7 @@ namespace search::fef {
class ITermFieldData
{
public:
- ITermFieldData(uint32_t fieldId)
+ ITermFieldData(uint32_t fieldId) noexcept
: _fieldId(fieldId),
_matching_doc_count(0),
_total_doc_count(1)
@@ -27,17 +27,17 @@ public:
*
* @return field id
**/
- uint32_t getFieldId() const { return _fieldId; }
+ uint32_t getFieldId() const noexcept { return _fieldId; }
/**
* Returns the number of documents matching this term.
*/
- uint32_t get_matching_doc_count() const { return _matching_doc_count; }
+ uint32_t get_matching_doc_count() const noexcept { return _matching_doc_count; }
/**
* Returns the total number of documents in the corpus.
*/
- uint32_t get_total_doc_count() const { return _total_doc_count; }
+ uint32_t get_total_doc_count() const noexcept { return _total_doc_count; }
/**
* Obtain the document frequency. This is a value between 0 and 1
@@ -45,14 +45,14 @@ public:
*
* @return document frequency
**/
- double getDocFreq() const {
+ double getDocFreq() const noexcept {
return (double)get_matching_doc_count() / (double)get_total_doc_count();
}
/**
* Sets the document frequency.
**/
- ITermFieldData &setDocFreq(uint32_t matching_doc_count, uint32_t total_doc_count) {
+ ITermFieldData &setDocFreq(uint32_t matching_doc_count, uint32_t total_doc_count) noexcept {
_matching_doc_count = matching_doc_count;
_total_doc_count = total_doc_count;
return *this;
@@ -64,7 +64,7 @@ public:
*
* @return match handle (or IllegalHandle)
**/
- TermFieldHandle getHandle() const {
+ TermFieldHandle getHandle() const noexcept {
return getHandle(MatchDataDetails::Normal);
}
diff --git a/searchlib/src/vespa/searchlib/fef/simpletermfielddata.cpp b/searchlib/src/vespa/searchlib/fef/simpletermfielddata.cpp
index 78378343b10..e1b4a3d732e 100644
--- a/searchlib/src/vespa/searchlib/fef/simpletermfielddata.cpp
+++ b/searchlib/src/vespa/searchlib/fef/simpletermfielddata.cpp
@@ -4,16 +4,4 @@
namespace search::fef {
-SimpleTermFieldData::SimpleTermFieldData(uint32_t fieldId)
- : ITermFieldData(fieldId),
- _handle(IllegalHandle)
-{
-}
-
-SimpleTermFieldData::SimpleTermFieldData(const ITermFieldData &rhs)
- : ITermFieldData(rhs),
- _handle(rhs.getHandle())
-{
-}
-
}
diff --git a/searchlib/src/vespa/searchlib/fef/simpletermfielddata.h b/searchlib/src/vespa/searchlib/fef/simpletermfielddata.h
index 7a70d484ff3..ec4abb53549 100644
--- a/searchlib/src/vespa/searchlib/fef/simpletermfielddata.h
+++ b/searchlib/src/vespa/searchlib/fef/simpletermfielddata.h
@@ -21,14 +21,20 @@ public:
/**
* Side-cast copy constructor.
**/
- SimpleTermFieldData(const ITermFieldData &rhs);
+ SimpleTermFieldData(const ITermFieldData &rhs) noexcept
+ : ITermFieldData(rhs),
+ _handle(rhs.getHandle())
+ {}
/**
* Create a new instance for the given field.
*
* @param fieldId the field being searched
**/
- SimpleTermFieldData(uint32_t fieldId);
+ SimpleTermFieldData(uint32_t fieldId) noexcept
+ : ITermFieldData(fieldId),
+ _handle(IllegalHandle)
+ {}
using ITermFieldData::getHandle;
@@ -40,7 +46,7 @@ public:
/**
* Sets the match handle for this field.
**/
- SimpleTermFieldData &setHandle(TermFieldHandle handle) {
+ SimpleTermFieldData &setHandle(TermFieldHandle handle) noexcept {
_handle = handle;
return *this;
}
diff --git a/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.cpp b/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.cpp
index da72374e7e3..fc85473a1b0 100644
--- a/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.cpp
+++ b/searchlib/src/vespa/searchlib/fef/test/queryenvironmentbuilder.cpp
@@ -11,7 +11,7 @@ QueryEnvironmentBuilder::QueryEnvironmentBuilder(QueryEnvironment &env,
{
}
-QueryEnvironmentBuilder::~QueryEnvironmentBuilder() { }
+QueryEnvironmentBuilder::~QueryEnvironmentBuilder() = default;
SimpleTermData &
QueryEnvironmentBuilder::addAllFields()