summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-07-26 17:11:00 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-07-31 17:04:19 +0200
commit4636bc4baf6c52005027f54188e2f3ddd71205a5 (patch)
tree75ea518819fe5f294f713c44960cee13a998c035 /document
parentc53f75542efbbe5e737744fe1104f7b8c56eb3b8 (diff)
Do not produce the whereClause until it is needed.
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/update/fieldpathupdate.cpp30
-rw-r--r--document/src/vespa/document/update/fieldpathupdate.h3
2 files changed, 11 insertions, 22 deletions
diff --git a/document/src/vespa/document/update/fieldpathupdate.cpp b/document/src/vespa/document/update/fieldpathupdate.cpp
index 29fee6063aa..7f246187de7 100644
--- a/document/src/vespa/document/update/fieldpathupdate.cpp
+++ b/document/src/vespa/document/update/fieldpathupdate.cpp
@@ -35,22 +35,17 @@ parseDocumentSelection(vespalib::stringref query, const DocumentTypeRepo& repo)
FieldPathUpdate::FieldPathUpdate() :
_originalFieldPath(),
_originalWhereClause(),
- _fieldPath(),
- _whereClause()
-{
-}
+ _fieldPath()
+{ }
FieldPathUpdate::FieldPathUpdate(const FieldPathUpdate &) = default;
FieldPathUpdate & FieldPathUpdate::operator =(const FieldPathUpdate &) = default;
-FieldPathUpdate::FieldPathUpdate(const DocumentTypeRepo& repo, const DataType& type,
+FieldPathUpdate::FieldPathUpdate(const DocumentTypeRepo &, const DataType& type,
stringref fieldPath, stringref whereClause) :
_originalFieldPath(fieldPath),
_originalWhereClause(whereClause),
- _fieldPath(),
- _whereClause(!_originalWhereClause.empty()
- ? parseDocumentSelection(_originalWhereClause, repo)
- : std::unique_ptr<select::Node>())
+ _fieldPath()
{
type.buildFieldPath(_fieldPath, _originalFieldPath);
}
@@ -69,10 +64,11 @@ FieldPathUpdate::applyTo(Document& doc) const
{
std::unique_ptr<IteratorHandler> handler(getIteratorHandler(doc));
- if (!_whereClause) {
+ if (_originalWhereClause.empty()) {
doc.iterateNested(_fieldPath, *handler);
} else {
- select::ResultList results = _whereClause->contains(doc);
+ std::unique_ptr<select::Node> whereClause = parseDocumentSelection(_originalWhereClause, *doc.getRepo());
+ select::ResultList results = whereClause->contains(doc);
for (select::ResultList::const_iterator i = results.begin(); i != results.end(); ++i) {
LOG(spam, "vars = %s", handler->getVariables().toString().c_str());
if (*i->second == select::Result::True) {
@@ -130,21 +126,15 @@ FieldPathUpdate::getString(ByteBuffer& buffer)
}
void
-FieldPathUpdate::deserialize(const DocumentTypeRepo& repo,
+FieldPathUpdate::deserialize(const DocumentTypeRepo&,
const DataType& type,
ByteBuffer& buffer, uint16_t)
{
_originalFieldPath = getString(buffer);
_originalWhereClause = getString(buffer);
- try {
- type.buildFieldPath(_fieldPath, _originalFieldPath);
- _whereClause = !_originalWhereClause.empty()
- ? parseDocumentSelection(_originalWhereClause, repo)
- : std::unique_ptr<select::Node>();
- } catch (const select::ParsingFailedException& e) {
- throw DeserializeException(e.what(), VESPA_STRLOC);
- }
+ type.buildFieldPath(_fieldPath, _originalFieldPath);
+
}
std::unique_ptr<FieldPathUpdate>
diff --git a/document/src/vespa/document/update/fieldpathupdate.h b/document/src/vespa/document/update/fieldpathupdate.h
index 60c1565316c..978481d33a0 100644
--- a/document/src/vespa/document/update/fieldpathupdate.h
+++ b/document/src/vespa/document/update/fieldpathupdate.h
@@ -107,8 +107,7 @@ private:
vespalib::string _originalFieldPath;
vespalib::string _originalWhereClause;
- FieldPath _fieldPath;
- std::shared_ptr<select::Node> _whereClause;
+ FieldPath _fieldPath;
};
}