summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2020-01-10 14:25:31 +0000
committerGeir Storli <geirst@verizonmedia.com>2020-01-10 14:25:31 +0000
commit4e13de16e6d74bf12fbfc45754fed4ba34e54b64 (patch)
tree2b0ae0b4912adb08cdef38ccffd6fe714108eb0f /document
parent46d808803c2bf8bb974cdf3d38ef6ceab4fc95f7 (diff)
Optimize handling of "matched-elements-only" when the input field as retrieved from the document instance.
In this case we now filter on matching elements while converting to slime, instead of converting to slime and then filter as done before.
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/fieldvalue/mapfieldvalue.h16
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);