aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-07-26 10:37:56 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-07-31 17:04:18 +0200
commitc4f93e038fcebf234b9a77e39cf929fe5e1887c2 (patch)
tree4f9405b509d83a26d21cd89ba55973be3c981bb5
parent1f35ee05ff5230a788e7231e48ce50cce8a6dbf9 (diff)
Include less and remove virtuality on FieldPath
-rw-r--r--document/src/vespa/document/base/fieldpath.cpp6
-rw-r--r--document/src/vespa/document/base/fieldpath.h24
-rw-r--r--document/src/vespa/document/datatype/mapdatatype.cpp29
-rw-r--r--document/src/vespa/document/datatype/structureddatatype.cpp2
-rw-r--r--document/src/vespa/document/update/addfieldpathupdate.cpp2
-rw-r--r--document/src/vespa/document/update/addfieldpathupdate.h2
-rw-r--r--document/src/vespa/document/update/assignfieldpathupdate.cpp1
-rw-r--r--document/src/vespa/document/update/assignfieldpathupdate.h6
-rw-r--r--document/src/vespa/document/update/fieldpathupdate.cpp14
-rw-r--r--document/src/vespa/document/update/fieldpathupdate.h34
-rw-r--r--document/src/vespa/document/update/updatevisitor.h2
-rw-r--r--document/src/vespa/document/update/valueupdate.h2
12 files changed, 62 insertions, 62 deletions
diff --git a/document/src/vespa/document/base/fieldpath.cpp b/document/src/vespa/document/base/fieldpath.cpp
index 041da6ad520..4911f910f1e 100644
--- a/document/src/vespa/document/base/fieldpath.cpp
+++ b/document/src/vespa/document/base/fieldpath.cpp
@@ -111,7 +111,7 @@ FieldPathEntry::FieldPathEntry(const DataType & dataType, const vespalib::string
const DataType &FieldPathEntry::getDataType() const
{
- return _fieldRef.get() ? _fieldRef->getDataType()
+ return _fieldRef ? _fieldRef->getDataType()
: *_dataType;
}
@@ -173,11 +173,11 @@ vespalib::string FieldPathEntry::parseKey(vespalib::string & key)
}
FieldPath::FieldPath()
- : Cloneable(), _path()
+ : _path()
{ }
FieldPath::FieldPath(const FieldPath& other)
- : Cloneable(), _path(other._path)
+ : _path(other._path)
{ }
FieldPath::~FieldPath() { }
diff --git a/document/src/vespa/document/base/fieldpath.h b/document/src/vespa/document/base/fieldpath.h
index 25c6a4ce448..a1681177780 100644
--- a/document/src/vespa/document/base/fieldpath.h
+++ b/document/src/vespa/document/base/fieldpath.h
@@ -6,9 +6,7 @@
#include <memory>
#include <vector>
-namespace vespalib {
-class ObjectVisitor;
-}
+namespace vespalib { class ObjectVisitor; }
namespace document {
@@ -31,9 +29,8 @@ public:
VARIABLE,
NONE
};
- typedef std::shared_ptr<const Field> FieldSP;
- typedef vespalib::CloneablePtr<DataType> DataTypeCP;
- typedef vespalib::CloneablePtr<FieldValue> FieldValueCP;
+ using FieldSP = std::shared_ptr<const Field>;
+ using FieldValueCP = vespalib::CloneablePtr<FieldValue>;
/**
Creates a empty field path entry.
@@ -53,8 +50,7 @@ public:
/**
Creates a field path entry for a map or wset key lookup.
*/
- FieldPathEntry(const DataType & dataType, const DataType& fillType,
- const FieldValueCP & lookupKey);
+ FieldPathEntry(const DataType & dataType, const DataType& fillType, const FieldValueCP & lookupKey);
/**
Creates a field path entry for a map key or value only traversal.
@@ -106,7 +102,7 @@ private:
//typedef std::deque<FieldPathEntry> FieldPath;
// Facade over FieldPathEntry container that exposes cloneability
-class FieldPath : public vespalib::Cloneable {
+class FieldPath {
typedef std::vector<FieldPathEntry> Container;
public:
typedef Container::reference reference;
@@ -120,6 +116,8 @@ public:
FieldPath();
FieldPath(const FieldPath& other);
FieldPath& operator=(const FieldPath& rhs);
+ FieldPath(FieldPath && other) noexcept = default;
+ FieldPath& operator=(FieldPath && rhs) noexcept = default;
~FieldPath();
template <typename InputIterator>
@@ -127,6 +125,8 @@ public:
: _path(first, last)
{ }
+ FieldPath * clone() const { return new FieldPath(*this); }
+
iterator insert(iterator pos, const FieldPathEntry& entry);
void push_back(const FieldPathEntry& entry);
@@ -157,11 +157,7 @@ public:
return _path[i];
}
- FieldPath* clone() const override {
- return new FieldPath(*this);
- }
-
- virtual void visitMembers(vespalib::ObjectVisitor &visitor) const;
+ void visitMembers(vespalib::ObjectVisitor &visitor) const;
template <typename IT>
class Range {
diff --git a/document/src/vespa/document/datatype/mapdatatype.cpp b/document/src/vespa/document/datatype/mapdatatype.cpp
index 9800749f16e..a11ea085931 100644
--- a/document/src/vespa/document/datatype/mapdatatype.cpp
+++ b/document/src/vespa/document/datatype/mapdatatype.cpp
@@ -65,20 +65,19 @@ MapDataType::buildFieldPathImpl(const DataType &dataType,
vespalib::string rest = remainFieldName;
vespalib::string keyValue = FieldPathEntry::parseKey(rest);
- FieldPath::UP path =
- valueType.buildFieldPath((rest[0] == '.') ? rest.substr(1) : rest);
- if (!path.get()) {
+ FieldPath::UP path = valueType.buildFieldPath((rest[0] == '.') ? rest.substr(1) : rest);
+ if (!path) {
return FieldPath::UP();
}
if (remainFieldName[1] == '$') {
- path->insert(path->begin(),
- FieldPathEntry(valueType, keyValue.substr(1)));
+ path->insert(path->begin(), FieldPathEntry(valueType, keyValue.substr(1)));
} else {
FieldValue::UP fv = keyType.createFieldValue();
*fv = keyValue;
- path->insert(path->begin(), FieldPathEntry(valueType, dataType,
- vespalib::CloneablePtr<FieldValue>(fv.release())));
+ path->insert(path->begin(),
+ FieldPathEntry(valueType, dataType,
+ vespalib::CloneablePtr<FieldValue>(fv.release())));
}
return path;
@@ -88,13 +87,11 @@ MapDataType::buildFieldPathImpl(const DataType &dataType,
endPos++;
}
- FieldPath::UP path
- = keyType.buildFieldPath(remainFieldName.substr(endPos));
- if (!path.get()) {
+ FieldPath::UP path = keyType.buildFieldPath(remainFieldName.substr(endPos));
+ if (!path) {
return FieldPath::UP();
}
- path->insert(path->begin(), FieldPathEntry(dataType, keyType,
- valueType, true, false));
+ path->insert(path->begin(), FieldPathEntry(dataType, keyType, valueType, true, false));
return path;
} else if (memcmp(remainFieldName.c_str(), "value", 5) == 0) {
size_t endPos = 5;
@@ -102,13 +99,11 @@ MapDataType::buildFieldPathImpl(const DataType &dataType,
endPos++;
}
- FieldPath::UP path
- = valueType.buildFieldPath(remainFieldName.substr(endPos));
- if (!path.get()) {
+ FieldPath::UP path = valueType.buildFieldPath(remainFieldName.substr(endPos));
+ if (!path) {
return FieldPath::UP();
}
- path->insert(path->begin(), FieldPathEntry(dataType, keyType,
- valueType, false, true));
+ path->insert(path->begin(), FieldPathEntry(dataType, keyType, valueType, false, true));
return path;
}
diff --git a/document/src/vespa/document/datatype/structureddatatype.cpp b/document/src/vespa/document/datatype/structureddatatype.cpp
index 344dbe5abef..34063c7d7e4 100644
--- a/document/src/vespa/document/datatype/structureddatatype.cpp
+++ b/document/src/vespa/document/datatype/structureddatatype.cpp
@@ -75,7 +75,7 @@ StructuredDataType::onBuildFieldPath(const vespalib::stringref & remainFieldName
if (hasField(currFieldName)) {
const document::Field &fp = getField(currFieldName);
FieldPath::UP fieldPath = fp.getDataType().buildFieldPath(subFieldName);
- if (!fieldPath.get()) {
+ if (!fieldPath) {
return FieldPath::UP();
}
fieldPath->insert(fieldPath->begin(), FieldPathEntry(fp));
diff --git a/document/src/vespa/document/update/addfieldpathupdate.cpp b/document/src/vespa/document/update/addfieldpathupdate.cpp
index 1cd1279a429..94c793bc0c7 100644
--- a/document/src/vespa/document/update/addfieldpathupdate.cpp
+++ b/document/src/vespa/document/update/addfieldpathupdate.cpp
@@ -4,9 +4,11 @@
#include <vespa/document/fieldvalue/iteratorhandler.h>
#include <vespa/document/fieldvalue/arrayfieldvalue.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/exceptions.h>
#include <ostream>
+#include <cassert>
using vespalib::nbostream;
diff --git a/document/src/vespa/document/update/addfieldpathupdate.h b/document/src/vespa/document/update/addfieldpathupdate.h
index 638fb21a26d..5864d064c80 100644
--- a/document/src/vespa/document/update/addfieldpathupdate.h
+++ b/document/src/vespa/document/update/addfieldpathupdate.h
@@ -5,6 +5,8 @@
namespace document {
+class ArrayFieldValue;
+
class AddFieldPathUpdate : public FieldPathUpdate
{
public:
diff --git a/document/src/vespa/document/update/assignfieldpathupdate.cpp b/document/src/vespa/document/update/assignfieldpathupdate.cpp
index 7fc998b68de..90f629dd588 100644
--- a/document/src/vespa/document/update/assignfieldpathupdate.cpp
+++ b/document/src/vespa/document/update/assignfieldpathupdate.cpp
@@ -6,6 +6,7 @@
#include <vespa/document/select/parser.h>
#include <vespa/document/select/variablemap.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/exceptions.h>
#include <boost/numeric/conversion/cast.hpp>
diff --git a/document/src/vespa/document/update/assignfieldpathupdate.h b/document/src/vespa/document/update/assignfieldpathupdate.h
index 44106aba4eb..6301e36953b 100644
--- a/document/src/vespa/document/update/assignfieldpathupdate.h
+++ b/document/src/vespa/document/update/assignfieldpathupdate.h
@@ -61,10 +61,10 @@ private:
std::unique_ptr<fieldvalue::IteratorHandler> getIteratorHandler(Document& doc) const override;
const DocumentTypeRepo *_repo;
- FieldValue::CP _newValue;
+ vespalib::CloneablePtr<FieldValue> _newValue;
vespalib::string _expression;
- bool _removeIfZero;
- bool _createMissingPath;
+ bool _removeIfZero;
+ bool _createMissingPath;
};
} // ns document
diff --git a/document/src/vespa/document/update/fieldpathupdate.cpp b/document/src/vespa/document/update/fieldpathupdate.cpp
index ccd9bd245b7..c6f597f74e3 100644
--- a/document/src/vespa/document/update/fieldpathupdate.cpp
+++ b/document/src/vespa/document/update/fieldpathupdate.cpp
@@ -4,6 +4,7 @@
#include <vespa/document/fieldvalue/iteratorhandler.h>
#include <vespa/document/select/parser.h>
#include <vespa/document/util/serializableexceptions.h>
+#include <vespa/document/util/bytebuffer.h>
#include <ostream>
#include <vespa/log/log.h>
@@ -38,10 +39,11 @@ FieldPathUpdate::FieldPathUpdate() :
{
}
-FieldPathUpdate::FieldPathUpdate(const DocumentTypeRepo& repo,
- const DataType& type,
- stringref fieldPath,
- stringref whereClause) :
+FieldPathUpdate::FieldPathUpdate(const FieldPathUpdate &) = default;
+FieldPathUpdate & FieldPathUpdate::operator =(const FieldPathUpdate &) = default;
+
+FieldPathUpdate::FieldPathUpdate(const DocumentTypeRepo& repo, const DataType& type,
+ stringref fieldPath, stringref whereClause) :
_originalFieldPath(fieldPath),
_originalWhereClause(whereClause),
_fieldPath(type.buildFieldPath(_originalFieldPath).release()),
@@ -49,7 +51,7 @@ FieldPathUpdate::FieldPathUpdate(const DocumentTypeRepo& repo,
? parseDocumentSelection(_originalWhereClause, repo)
: std::unique_ptr<select::Node>())
{
- if (!_fieldPath.get()) {
+ if (!_fieldPath) {
throw IllegalArgumentException(
make_string("Could not create field path update for: path='%s', where='%s'",
fieldPath.c_str(), whereClause.c_str()), VESPA_STRLOC);
@@ -142,7 +144,7 @@ FieldPathUpdate::deserialize(const DocumentTypeRepo& repo,
try {
_fieldPath = type.buildFieldPath(_originalFieldPath).release();
- if (!_fieldPath.get()) {
+ if (!_fieldPath) {
throw DeserializeException(make_string("Invalid field path: '%s'", _originalFieldPath.c_str()), VESPA_STRLOC);
}
_whereClause = !_originalWhereClause.empty()
diff --git a/document/src/vespa/document/update/fieldpathupdate.h b/document/src/vespa/document/update/fieldpathupdate.h
index 7431d305494..49f11a5c3f2 100644
--- a/document/src/vespa/document/update/fieldpathupdate.h
+++ b/document/src/vespa/document/update/fieldpathupdate.h
@@ -2,14 +2,11 @@
#pragma once
#include "updatevisitor.h"
-#include "valueupdate.h"
-#include <vespa/document/datatype/datatype.h>
-#include <vespa/document/util/serializable.h>
-#include <vespa/document/util/xmlserializable.h>
-#include <vespa/document/fieldvalue/fieldvalue.h>
-#include <vespa/document/select/node.h>
-#include <vespa/document/select/resultlist.h>
+#include <vespa/document/util/printable.h>
+#include <vespa/document/util/identifiableid.h>
+#include <vespa/vespalib/objects/identifiable.h>
#include <vespa/vespalib/objects/cloneable.h>
+#include <vespa/vespalib/stllike/string.h>
namespace document {
@@ -18,26 +15,31 @@ class DocumentTypeRepo;
class Field;
class FieldValue;
class BucketIdFactory;
+class Document;
+class DataType;
+class FieldPath;
+
+namespace select { class Node; }
+namespace fieldvalue { class IteratorHandler; }
class FieldPathUpdate : public vespalib::Cloneable,
public Printable,
public vespalib::Identifiable
{
protected:
- typedef vespalib::stringref stringref;
+ using stringref = vespalib::stringref;
/** To be used for deserialization */
FieldPathUpdate();
+ FieldPathUpdate(const FieldPathUpdate &);
+ FieldPathUpdate & operator =(const FieldPathUpdate &);
static vespalib::string getString(ByteBuffer& buffer);
public:
- typedef select::ResultList::VariableMap VariableMap;
- typedef std::shared_ptr<FieldPathUpdate> SP;
- typedef vespalib::CloneablePtr<FieldPathUpdate> CP;
-
- FieldPathUpdate(const DocumentTypeRepo& repo,
- const DataType& type,
- stringref fieldPath,
- stringref whereClause = stringref());
+ using SP = std::shared_ptr<FieldPathUpdate>;
+ using CP = vespalib::CloneablePtr<FieldPathUpdate>;
+
+ FieldPathUpdate(const DocumentTypeRepo& repo, const DataType& type,
+ stringref fieldPath, stringref whereClause = stringref());
~FieldPathUpdate();
diff --git a/document/src/vespa/document/update/updatevisitor.h b/document/src/vespa/document/update/updatevisitor.h
index 30687e426ba..9c80e4ee5d8 100644
--- a/document/src/vespa/document/update/updatevisitor.h
+++ b/document/src/vespa/document/update/updatevisitor.h
@@ -32,5 +32,7 @@ struct UpdateVisitor {
virtual void visit(const RemoveFieldPathUpdate &value) = 0;
};
+#define ACCEPT_UPDATE_VISITOR void accept(UpdateVisitor & visitor) const override { visitor.visit(*this); }
+
} // namespace document
diff --git a/document/src/vespa/document/update/valueupdate.h b/document/src/vespa/document/update/valueupdate.h
index 37b3dd337dd..25824799942 100644
--- a/document/src/vespa/document/update/valueupdate.h
+++ b/document/src/vespa/document/update/valueupdate.h
@@ -32,8 +32,6 @@ class DocumentTypeRepo;
class Field;
class FieldValue;
-#define ACCEPT_UPDATE_VISITOR void accept(UpdateVisitor & visitor) const override { visitor.visit(*this); }
-
class ValueUpdate : public vespalib::Identifiable,
public Printable,
public vespalib::Cloneable,