diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-10 15:51:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-10 15:51:55 +0100 |
commit | 6af036ff1be58aed8806610d5769952ac0192bdc (patch) | |
tree | 7fc52b0477bac6afab4d8f402c4df517af993222 /document | |
parent | cd168363b8f09ccc9d830b97b077ee09c5d5b4f1 (diff) | |
parent | 4e13de16e6d74bf12fbfc45754fed4ba34e54b64 (diff) |
Merge pull request #11748 from vespa-engine/geirst/optimize-matched-elements-only-filter
Optimize handling of "matched-elements-only" when the input field as …
Diffstat (limited to 'document')
-rw-r--r-- | document/src/vespa/document/fieldvalue/mapfieldvalue.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/document/src/vespa/document/fieldvalue/mapfieldvalue.h b/document/src/vespa/document/fieldvalue/mapfieldvalue.h index d761a37612e..bed4275d61f 100644 --- a/document/src/vespa/document/fieldvalue/mapfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/mapfieldvalue.h @@ -72,8 +72,8 @@ public: mutable pair _current; }; class const_iterator { - typedef std::pair<const FieldValue *, const FieldValue *> pair; public: + typedef std::pair<const FieldValue *, const FieldValue *> pair; const_iterator(const MapFieldValue & map, size_t index) : _map(&map), _index(index) { } bool operator == (const const_iterator & rhs) const { return _map == rhs._map && _index == rhs._index; } bool operator != (const const_iterator & rhs) const { return _map != rhs._map || _index != rhs._index; } @@ -147,6 +147,20 @@ public: const_iterator find(const FieldValue& fv) const; iterator find(const FieldValue& fv); + bool has_no_erased_keys() const { + return (_keys->size() == _count) && (_values->size() == _count); + } + + /** + * Returns the key-value pair at the given position in the underlying arrays. + * + * Note: Should only be used when has_no_erased_keys() returns true. + * Otherwise you might access elements that are conceptually removed. + */ + const_iterator::pair operator[](size_t idx) const { + return const_iterator::pair(&(*_keys)[idx], &(*_values)[idx]); + } + FieldValue::UP createValue() const; DECLARE_IDENTIFIABLE_ABSTRACT(MapFieldValue); |