aboutsummaryrefslogtreecommitdiffstats
path: root/vsm
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-04-24 12:15:54 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-04-24 12:15:54 +0200
commit9e383f5102e1659592b0c8b5ff3d06012e760b85 (patch)
tree6848b18eae7c60f1d5e99267233c99facbf57e67 /vsm
parentbbf12235b64545d624352840eff4c43eb4021578 (diff)
Put the start and end iterators into a Range class for simplicity and readability.
Diffstat (limited to 'vsm')
-rw-r--r--vsm/src/tests/docsum/docsum.cpp2
-rw-r--r--vsm/src/vespa/vsm/common/storagedocument.cpp13
-rw-r--r--vsm/src/vespa/vsm/common/storagedocument.h16
-rw-r--r--vsm/src/vespa/vsm/searcher/fieldsearcher.cpp2
4 files changed, 16 insertions, 17 deletions
diff --git a/vsm/src/tests/docsum/docsum.cpp b/vsm/src/tests/docsum/docsum.cpp
index cb364c0b65e..d854421ecb5 100644
--- a/vsm/src/tests/docsum/docsum.cpp
+++ b/vsm/src/tests/docsum/docsum.cpp
@@ -98,7 +98,7 @@ void
DocsumTest::assertFlattenDocsumWriter(FlattenDocsumWriter & fdw, const FieldValue & fv, const std::string & exp)
{
FieldPath empty;
- fv.iterateNested(empty.begin(), empty.end(), fdw);
+ fv.iterateNested(empty.getFullRange(), fdw);
std::string actual(fdw.getResult().getBuffer(), fdw.getResult().getPos());
EXPECT_EQUAL(actual, exp);
}
diff --git a/vsm/src/vespa/vsm/common/storagedocument.cpp b/vsm/src/vespa/vsm/common/storagedocument.cpp
index 83eae8a2403..ff9940f30bc 100644
--- a/vsm/src/vespa/vsm/common/storagedocument.cpp
+++ b/vsm/src/vespa/vsm/common/storagedocument.cpp
@@ -7,6 +7,8 @@
#include <vespa/log/log.h>
LOG_SETUP(".vsm.storagedocument");
+using NestedIterator = document::FieldValue::PathRange;
+
namespace vsm {
StorageDocument::StorageDocument(document::Document::UP doc, const SharedFieldPathMap & fim, size_t fieldNoLimit) :
@@ -21,7 +23,7 @@ StorageDocument::~StorageDocument() { }
namespace {
FieldPath _emptyFieldPath;
- StorageDocument::SubDocument _empySubDocument(NULL, _emptyFieldPath.begin(), _emptyFieldPath.end());
+ StorageDocument::SubDocument _empySubDocument(NULL, _emptyFieldPath.getFullRange());
}
const StorageDocument::SubDocument &
@@ -31,12 +33,11 @@ StorageDocument::getComplexField(FieldIdT fId) const
const FieldPath & fp = (*_fieldMap)[fId];
if ( ! fp.empty() ) {
const document::StructuredFieldValue * sfv = _doc.get();
- FieldPath::const_iterator it = fp.begin();
- FieldPath::const_iterator mt = fp.end();
- const document::FieldPathEntry& fvInfo = *it;
+ NestedIterator nested = fp.getFullRange();
+ const document::FieldPathEntry& fvInfo = nested.cur();
bool ok = sfv->getValue(fvInfo.getFieldRef(), fvInfo.getFieldValueToSet());
if (ok) {
- SubDocument tmp(&fvInfo.getFieldValueToSet(), it + 1, mt);
+ SubDocument tmp(&fvInfo.getFieldValueToSet(), nested.next());
_cachedFields[fId].swap(tmp);
}
} else {
@@ -70,7 +71,7 @@ bool StorageDocument::setField(FieldIdT fId, document::FieldValue::UP fv)
bool ok(fId < _cachedFields.size());
if (ok) {
const FieldPath & fp = (*_fieldMap)[fId];
- SubDocument tmp(fv.get(), fp.end(), fp.end());
+ SubDocument tmp(fv.get(), NestedIterator(fp.end(), fp.end()));
_cachedFields[fId].swap(tmp);
_backedFields.emplace_back(std::move(fv));
}
diff --git a/vsm/src/vespa/vsm/common/storagedocument.h b/vsm/src/vespa/vsm/common/storagedocument.h
index 003c827b80f..fd93b5cc5e9 100644
--- a/vsm/src/vespa/vsm/common/storagedocument.h
+++ b/vsm/src/vespa/vsm/common/storagedocument.h
@@ -18,25 +18,23 @@ public:
class SubDocument {
public:
SubDocument() : _fieldValue(NULL) {}
- SubDocument(document::FieldValue *fv, FieldPath::const_iterator it, FieldPath::const_iterator mt) :
+ SubDocument(document::FieldValue *fv, document::FieldValue::PathRange nested) :
_fieldValue(fv),
- _it(it),
- _mt(mt)
+ _range(nested)
{ }
const document::FieldValue *getFieldValue() const { return _fieldValue; }
void setFieldValue(document::FieldValue *fv) { _fieldValue = fv; }
- FieldPath::const_iterator begin() const { return _it; }
- FieldPath::const_iterator end() const { return _mt; }
+ const document::FieldValue::PathRange & getRange() const { return _range; }
void swap(SubDocument &rhs) {
std::swap(_fieldValue, rhs._fieldValue);
- std::swap(_it, rhs._it);
- std::swap(_mt, rhs._mt);
+ std::swap(_range, rhs._range);
}
private:
+ FieldPath::const_iterator begin() const;
+ FieldPath::const_iterator end() const;
document::FieldValue *_fieldValue;
- FieldPath::const_iterator _it;
- FieldPath::const_iterator _mt;
+ document::FieldValue::PathRange _range;
};
public:
StorageDocument(document::Document::UP doc, const SharedFieldPathMap &fim, size_t fieldNoLimit);
diff --git a/vsm/src/vespa/vsm/searcher/fieldsearcher.cpp b/vsm/src/vespa/vsm/searcher/fieldsearcher.cpp
index 7459d5d9be7..decc1e0364a 100644
--- a/vsm/src/vespa/vsm/searcher/fieldsearcher.cpp
+++ b/vsm/src/vespa/vsm/searcher/fieldsearcher.cpp
@@ -265,7 +265,7 @@ bool FieldSearcher::onSearch(const StorageDocument & doc)
if (sub.getFieldValue() != NULL) {
LOG(spam, "onSearch %s : %s", sub.getFieldValue()->getClass().name(), sub.getFieldValue()->toString().c_str());
IteratorHandler ih(*this);
- sub.getFieldValue()->iterateNested(sub.begin(), sub.end(), ih);
+ sub.getFieldValue()->iterateNested(sub.getRange(), ih);
}
return retval;
}