summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-06-07 18:55:25 +0200
committerHenning Baldersheim <balder@oath.com>2018-06-12 09:56:59 +0200
commitdeeb1f23b97c43195a20c5981df3a71c42ec6f3f (patch)
treebb4242f2b74d90dab15c0beb4a43ce8fbf95a247 /document
parent498bd3df67182d16e021fccd5514c578838ba2bf (diff)
Reduce code visibility
Conflicts: document/src/vespa/document/update/documentupdate.h document/src/vespa/document/update/mapvalueupdate.cpp
Diffstat (limited to 'document')
-rw-r--r--document/src/tests/documentupdatetestcase.cpp1
-rw-r--r--document/src/tests/fieldpathupdatetestcase.cpp2
-rw-r--r--document/src/tests/testxml.cpp2
-rw-r--r--document/src/vespa/document/base/documentid.cpp12
-rw-r--r--document/src/vespa/document/base/documentid.h19
-rw-r--r--document/src/vespa/document/base/fieldpath.h1
-rw-r--r--document/src/vespa/document/datatype/datatype.h4
-rw-r--r--document/src/vespa/document/datatype/structureddatatype.cpp6
-rw-r--r--document/src/vespa/document/serialization/vespadocumentserializer.cpp1
-rw-r--r--document/src/vespa/document/update/addvalueupdate.cpp1
-rw-r--r--document/src/vespa/document/update/arithmeticvalueupdate.cpp10
-rw-r--r--document/src/vespa/document/update/assignvalueupdate.cpp10
-rw-r--r--document/src/vespa/document/update/documentupdate.cpp1
-rw-r--r--document/src/vespa/document/update/documentupdate.h5
-rw-r--r--document/src/vespa/document/update/fieldpathupdate.h3
-rw-r--r--document/src/vespa/document/update/fieldupdate.cpp1
-rw-r--r--document/src/vespa/document/update/fieldupdate.h1
-rw-r--r--document/src/vespa/document/update/mapvalueupdate.cpp37
-rw-r--r--document/src/vespa/document/update/removevalueupdate.cpp25
-rw-r--r--document/src/vespa/document/update/valueupdate.cpp5
-rw-r--r--document/src/vespa/document/update/valueupdate.h3
-rw-r--r--document/src/vespa/document/util/printable.h10
-rw-r--r--document/src/vespa/document/util/serializable.cpp14
-rw-r--r--document/src/vespa/document/util/serializable.h32
24 files changed, 62 insertions, 144 deletions
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp
index 67fafadd8cd..6b52d4018b3 100644
--- a/document/src/tests/documentupdatetestcase.cpp
+++ b/document/src/tests/documentupdatetestcase.cpp
@@ -14,6 +14,7 @@
#include <vespa/document/update/removevalueupdate.h>
#include <vespa/document/update/valueupdate.h>
#include <vespa/document/serialization/vespadocumentserializer.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/document/repo/configbuilder.h>
#include <vespa/document/repo/documenttyperepo.h>
diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp
index 7058af95828..b240f322e4b 100644
--- a/document/src/tests/fieldpathupdatetestcase.cpp
+++ b/document/src/tests/fieldpathupdatetestcase.cpp
@@ -11,6 +11,8 @@
#include <vespa/document/repo/configbuilder.h>
#include <vespa/document/repo/documenttyperepo.h>
+#include <vespa/document/util/bytebuffer.h>
+
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/document/serialization/vespadocumentserializer.h>
#include <vespa/vespalib/objects/nbostream.h>
diff --git a/document/src/tests/testxml.cpp b/document/src/tests/testxml.cpp
index 76cb13c78e9..4cc1306ff45 100644
--- a/document/src/tests/testxml.cpp
+++ b/document/src/tests/testxml.cpp
@@ -1,6 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
#include <vespa/document/base/testdocrepo.h>
#include <cppunit/extensions/HelperMacros.h>
#include <vespa/document/update/documentupdate.h>
@@ -11,6 +10,7 @@
#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/vespalib/text/stringtokenizer.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/testkit/test_kit.h>
using vespalib::StringTokenizer;
diff --git a/document/src/vespa/document/base/documentid.cpp b/document/src/vespa/document/base/documentid.cpp
index d5e84e48e38..d2eae01922d 100644
--- a/document/src/vespa/document/base/documentid.cpp
+++ b/document/src/vespa/document/base/documentid.cpp
@@ -15,7 +15,7 @@ DocumentId::DocumentId()
{
}
-DocumentId::DocumentId(const vespalib::stringref & id)
+DocumentId::DocumentId(vespalib::stringref id)
: Printable(),
_globalId(),
_id(IdString::createIdString(id.c_str(), id.size()).release())
@@ -42,6 +42,11 @@ DocumentId::toString() const {
return _id->toString();
}
+void DocumentId::set(vespalib::stringref id) {
+ _id.reset(IdString::createIdString(id).release());
+ _globalId.first = false;
+}
+
void
DocumentId::print(std::ostream& out, bool verbose, const std::string& indent) const
{
@@ -61,6 +66,11 @@ DocumentId::getSerializedSize() const
return _id->toString().size() + 1;
}
+void DocumentId::swap(DocumentId & rhs) {
+ _id.swap(rhs._id);
+ std::swap(_globalId, rhs._globalId);
+}
+
void
DocumentId::calculateGlobalId() const
{
diff --git a/document/src/vespa/document/base/documentid.h b/document/src/vespa/document/base/documentid.h
index 319ec1187ba..4611de73741 100644
--- a/document/src/vespa/document/base/documentid.h
+++ b/document/src/vespa/document/base/documentid.h
@@ -43,20 +43,16 @@ public:
*
* @throws IdParseException If the identifier given is invalid.
*/
- explicit DocumentId(const vespalib::stringref & id);
+ explicit DocumentId(vespalib::stringref id);
- void set(const vespalib::stringref & id) {
- _id.reset(IdString::createIdString(id).release());
- _globalId.first = false;
- }
+ void set(vespalib::stringref id);
/**
Hides the printable toString() for effiency reasons.
*/
vespalib::string toString() const;
- void print(std::ostream& out, bool verbose,
- const std::string& indent) const override;
+ void print(std::ostream& out, bool verbose, const std::string& indent) const override;
bool operator==(const DocumentId& other) const { return *_id == *other._id; }
bool operator!=(const DocumentId& other) const { return ! (*_id == *other._id); }
@@ -71,16 +67,11 @@ public:
}
DocumentId* clone() const { return new DocumentId(*this); }
-
virtual size_t getSerializedSize() const;
- void swap(DocumentId & rhs) {
- _id.swap(rhs._id);
- std::swap(_globalId, rhs._globalId);
- }
-
+ void swap(DocumentId & rhs);
private:
mutable std::pair<bool, GlobalId> _globalId;
- IdString::CP _id;
+ vespalib::CloneablePtr<IdString> _id;
void calculateGlobalId() const;
};
diff --git a/document/src/vespa/document/base/fieldpath.h b/document/src/vespa/document/base/fieldpath.h
index 578b54faf56..42248bf2595 100644
--- a/document/src/vespa/document/base/fieldpath.h
+++ b/document/src/vespa/document/base/fieldpath.h
@@ -4,7 +4,6 @@
#include "field.h"
#include <vespa/vespalib/objects/cloneable.h>
#include <vespa/document/util/identifiableid.h>
-#include <memory>
#include <vector>
namespace vespalib { class ObjectVisitor; }
diff --git a/document/src/vespa/document/datatype/datatype.h b/document/src/vespa/document/datatype/datatype.h
index 11c321f29e6..fae33ea2a42 100644
--- a/document/src/vespa/document/datatype/datatype.h
+++ b/document/src/vespa/document/datatype/datatype.h
@@ -12,9 +12,6 @@
#include <vespa/document/util/identifiableid.h>
#include <vespa/document/util/printable.h>
-#include <memory>
-#include <vector>
-#include <vespa/document/base/fieldpath.h>
namespace document {
@@ -24,6 +21,7 @@ class NumericDataType;
class PrimitiveDataType;
class DocumentType;
class WeightedSetDataType;
+class FieldPath;
class DataType : public vespalib::Cloneable,
public Printable,
diff --git a/document/src/vespa/document/datatype/structureddatatype.cpp b/document/src/vespa/document/datatype/structureddatatype.cpp
index e054cf24706..41c0cd6f4e7 100644
--- a/document/src/vespa/document/datatype/structureddatatype.cpp
+++ b/document/src/vespa/document/datatype/structureddatatype.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "structureddatatype.h"
+#include <vespa/document/base/fieldpath.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/document/base/exceptions.h>
@@ -10,10 +11,7 @@ namespace document {
IMPLEMENT_IDENTIFIABLE_ABSTRACT(StructuredDataType, DataType);
-StructuredDataType::StructuredDataType() :
- DataType()
-{
-}
+StructuredDataType::StructuredDataType() = default;
StructuredDataType::StructuredDataType(const vespalib::stringref &name)
: DataType(name, createId(name))
diff --git a/document/src/vespa/document/serialization/vespadocumentserializer.cpp b/document/src/vespa/document/serialization/vespadocumentserializer.cpp
index 919f02a5fee..1a628ea2618 100644
--- a/document/src/vespa/document/serialization/vespadocumentserializer.cpp
+++ b/document/src/vespa/document/serialization/vespadocumentserializer.cpp
@@ -23,6 +23,7 @@
#include <vespa/document/datatype/weightedsetdatatype.h>
#include <vespa/document/update/updates.h>
#include <vespa/document/update/fieldpathupdates.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/data/slime/binary_format.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/data/databuffer.h>
diff --git a/document/src/vespa/document/update/addvalueupdate.cpp b/document/src/vespa/document/update/addvalueupdate.cpp
index 73f106f8559..8ac1ee301eb 100644
--- a/document/src/vespa/document/update/addvalueupdate.cpp
+++ b/document/src/vespa/document/update/addvalueupdate.cpp
@@ -5,6 +5,7 @@
#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
#include <vespa/document/util/serializableexceptions.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/xmlstream.h>
diff --git a/document/src/vespa/document/update/arithmeticvalueupdate.cpp b/document/src/vespa/document/update/arithmeticvalueupdate.cpp
index 61fc9d93563..b84dbe0f366 100644
--- a/document/src/vespa/document/update/arithmeticvalueupdate.cpp
+++ b/document/src/vespa/document/update/arithmeticvalueupdate.cpp
@@ -2,6 +2,7 @@
#include "arithmeticvalueupdate.h"
#include <vespa/document/base/field.h>
#include <vespa/document/fieldvalue/fieldvalues.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/xmlstream.h>
@@ -9,8 +10,7 @@ using vespalib::IllegalArgumentException;
using vespalib::IllegalStateException;
using namespace vespalib::xml;
-namespace document
-{
+namespace document {
IMPLEMENT_IDENTIFIABLE(ArithmeticValueUpdate, ValueUpdate);
@@ -22,8 +22,7 @@ bool
ArithmeticValueUpdate::operator==(const ValueUpdate& other) const
{
if (other.getClass().id() != ArithmeticValueUpdate::classId) return false;
- const ArithmeticValueUpdate& o(
- static_cast<const ArithmeticValueUpdate&>(other));
+ const ArithmeticValueUpdate& o(static_cast<const ArithmeticValueUpdate&>(other));
if (_operator != o._operator) return false;
if (_operand != o._operand) return false;
return true;
@@ -115,8 +114,7 @@ ArithmeticValueUpdate::applyTo(const std::string & value) const
void
ArithmeticValueUpdate::print(std::ostream& out, bool, const std::string& indent) const
{
- out << indent << "ArithmeticValueUpdate(" << operatorNameC[_operator]
- << " " << _operand << ")";
+ out << indent << "ArithmeticValueUpdate(" << operatorNameC[_operator] << " " << _operand << ")";
}
void
diff --git a/document/src/vespa/document/update/assignvalueupdate.cpp b/document/src/vespa/document/update/assignvalueupdate.cpp
index 81d4097d13b..fb38a78690b 100644
--- a/document/src/vespa/document/update/assignvalueupdate.cpp
+++ b/document/src/vespa/document/update/assignvalueupdate.cpp
@@ -4,11 +4,11 @@
#include <vespa/document/base/field.h>
#include <vespa/document/fieldvalue/fieldvalues.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 <vespa/vespalib/util/xmlstream.h>
-
using vespalib::IllegalArgumentException;
using vespalib::IllegalStateException;
using vespalib::nbostream;
@@ -18,14 +18,14 @@ namespace document {
IMPLEMENT_IDENTIFIABLE(AssignValueUpdate, ValueUpdate);
-AssignValueUpdate::AssignValueUpdate() : ValueUpdate(), _value() {}
+AssignValueUpdate::AssignValueUpdate() = default;
AssignValueUpdate::AssignValueUpdate(const FieldValue& value)
: ValueUpdate(),
_value(value.clone())
{
}
-AssignValueUpdate::~AssignValueUpdate() {}
+AssignValueUpdate::~AssignValueUpdate() = default;
// Declare content bits.
static const unsigned char CONTENT_HASVALUE = 0x01;
@@ -90,9 +90,7 @@ AssignValueUpdate::printXml(XmlOutputStream& xos) const
// Deserialize this update from the given buffer.
void
-AssignValueUpdate::deserialize(
- const DocumentTypeRepo& repo, const DataType& type,
- ByteBuffer& buffer, uint16_t version)
+AssignValueUpdate::deserialize(const DocumentTypeRepo& repo, const DataType& type, ByteBuffer& buffer, uint16_t version)
{
// Read content bit vector.
unsigned char content = 0x00;
diff --git a/document/src/vespa/document/update/documentupdate.cpp b/document/src/vespa/document/update/documentupdate.cpp
index a3cc2a95155..30b760a6102 100644
--- a/document/src/vespa/document/update/documentupdate.cpp
+++ b/document/src/vespa/document/update/documentupdate.cpp
@@ -7,6 +7,7 @@
#include <vespa/document/util/serializableexceptions.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/document/util/bufferexceptions.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/document/base/exceptions.h>
#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/repo/documenttyperepo.h>
diff --git a/document/src/vespa/document/update/documentupdate.h b/document/src/vespa/document/update/documentupdate.h
index a7f9d13d693..c4b351674b5 100644
--- a/document/src/vespa/document/update/documentupdate.h
+++ b/document/src/vespa/document/update/documentupdate.h
@@ -28,9 +28,7 @@
#include "fieldupdate.h"
#include "fieldpathupdate.h"
#include <vespa/document/base/documentid.h>
-#include <vespa/document/base/field.h>
-#include <vespa/document/fieldvalue/fieldvalue.h>
-#include <vespa/document/util/bytebuffer.h>
+#include <vespa/vespalib/objects/nbostream.h>
namespace document {
@@ -166,4 +164,3 @@ private:
};
} // document
-
diff --git a/document/src/vespa/document/update/fieldpathupdate.h b/document/src/vespa/document/update/fieldpathupdate.h
index 6629aa74aee..76d529fec68 100644
--- a/document/src/vespa/document/update/fieldpathupdate.h
+++ b/document/src/vespa/document/update/fieldpathupdate.h
@@ -4,9 +4,6 @@
#include "updatevisitor.h"
#include <vespa/document/base/fieldpath.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>
namespace document {
diff --git a/document/src/vespa/document/update/fieldupdate.cpp b/document/src/vespa/document/update/fieldupdate.cpp
index 277d6467ae8..52fe0071b94 100644
--- a/document/src/vespa/document/update/fieldupdate.cpp
+++ b/document/src/vespa/document/update/fieldupdate.cpp
@@ -4,6 +4,7 @@
#include <vespa/document/base/exceptions.h>
#include <vespa/document/fieldvalue/document.h>
#include <vespa/document/datatype/documenttype.h>
+#include <vespa/document/util/bytebuffer.h>
namespace document {
diff --git a/document/src/vespa/document/update/fieldupdate.h b/document/src/vespa/document/update/fieldupdate.h
index 569fb21fe1c..fc94df605af 100644
--- a/document/src/vespa/document/update/fieldupdate.h
+++ b/document/src/vespa/document/update/fieldupdate.h
@@ -15,7 +15,6 @@
#include "valueupdate.h"
#include <vespa/document/base/field.h>
-#include <vespa/document/util/serializable.h>
namespace document {
diff --git a/document/src/vespa/document/update/mapvalueupdate.cpp b/document/src/vespa/document/update/mapvalueupdate.cpp
index 09cec34c388..568b661e03d 100644
--- a/document/src/vespa/document/update/mapvalueupdate.cpp
+++ b/document/src/vespa/document/update/mapvalueupdate.cpp
@@ -4,9 +4,10 @@
#include <vespa/document/datatype/weightedsetdatatype.h>
#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
-#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/document/util/serializableexceptions.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/util/xmlstream.h>
+#include <vespa/vespalib/objects/nbostream.h>
using vespalib::IllegalArgumentException;
using vespalib::IllegalStateException;
@@ -25,7 +26,7 @@ MapValueUpdate::MapValueUpdate(const FieldValue& key, const ValueUpdate& update)
MapValueUpdate::MapValueUpdate(const MapValueUpdate &) = default;
MapValueUpdate & MapValueUpdate::operator = (const MapValueUpdate &) = default;
-MapValueUpdate::~MapValueUpdate() {}
+MapValueUpdate::~MapValueUpdate() = default;
bool
MapValueUpdate::operator==(const ValueUpdate& other) const
@@ -45,18 +46,15 @@ MapValueUpdate::checkCompatibility(const Field& field) const
if (field.getDataType().getClass().id() == ArrayDataType::classId) {
if (_key->getClass().id() != IntFieldValue::classId) {
throw IllegalArgumentException(vespalib::make_string(
- "Key for field '%s' is of wrong type (expected '%s', "
- "was '%s').",
+ "Key for field '%s' is of wrong type (expected '%s', was '%s').",
field.getName().c_str(), DataType::INT->toString().c_str(),
_key->getDataType()->toString().c_str()), VESPA_STRLOC);
}
} else if (field.getDataType().getClass().id() == WeightedSetDataType::classId) {
- const WeightedSetDataType& type =
- static_cast<const WeightedSetDataType&>(field.getDataType());
+ const WeightedSetDataType& type = static_cast<const WeightedSetDataType&>(field.getDataType());
if (!type.getNestedType().isValueType(*_key)) {
throw IllegalArgumentException(vespalib::make_string(
- "Key for field '%s' is of wrong type (expected '%s', "
- "was '%s').",
+ "Key for field '%s' is of wrong type (expected '%s', was '%s').",
field.getName().c_str(), DataType::INT->toString().c_str(),
_key->getDataType()->toString().c_str()), VESPA_STRLOC);
}
@@ -81,11 +79,8 @@ MapValueUpdate::applyTo(FieldValue& value) const
if (!_update->applyTo(val[_key->getAsInt()])) {
val.remove(_key->getAsInt());
}
- } else if (value.getDataType()->getClass().id()
- == WeightedSetDataType::classId)
- {
- const WeightedSetDataType& type(
- static_cast<const WeightedSetDataType&>(*value.getDataType()));
+ } else if (value.getDataType()->getClass().id() == WeightedSetDataType::classId) {
+ const WeightedSetDataType& type(static_cast<const WeightedSetDataType&>(*value.getDataType()));
WeightedSetFieldValue& val(static_cast<WeightedSetFieldValue&>(value));
WeightedSetFieldValue::iterator it = val.find(*_key);
if (it == val.end() && type.createIfNonExistent()) {
@@ -133,9 +128,7 @@ MapValueUpdate::printXml(XmlOutputStream& xos) const
// Deserialize this update from the given buffer.
void
-MapValueUpdate::deserialize(const DocumentTypeRepo& repo,
- const DataType& type,
- ByteBuffer& buffer, uint16_t version)
+MapValueUpdate::deserialize(const DocumentTypeRepo& repo, const DataType& type, ByteBuffer& buffer, uint16_t version)
{
nbostream stream(buffer.getBufferAtPos(), buffer.getRemaining());
VespaDocumentDeserializer deserializer(repo, stream, version);
@@ -146,24 +139,20 @@ MapValueUpdate::deserialize(const DocumentTypeRepo& repo,
deserializer.read(*_key);
buffer.incPos(buffer.getRemaining() - stream.size());
const ArrayDataType& arrayType = static_cast<const ArrayDataType&>(type);
- _update.reset(ValueUpdate::createInstance(
- repo, arrayType.getNestedType(), buffer, version).release());
+ _update.reset(ValueUpdate::createInstance(repo, arrayType.getNestedType(), buffer, version).release());
break;
}
case WeightedSetDataType::classId:
{
- const WeightedSetDataType& wset(
- static_cast<const WeightedSetDataType&>(type));
+ const WeightedSetDataType& wset(static_cast<const WeightedSetDataType&>(type));
_key.reset(wset.getNestedType().createFieldValue().release());
deserializer.read(*_key);
buffer.incPos(buffer.getRemaining() - stream.size());
- _update.reset(ValueUpdate::createInstance(
- repo, *DataType::INT, buffer, version).release());
+ _update.reset(ValueUpdate::createInstance(repo, *DataType::INT, buffer, version).release());
break;
}
default:
- throw DeserializeException("Can not perform map update on type "
- + type.toString() + ".", VESPA_STRLOC);
+ throw DeserializeException("Can not perform map update on type " + type.toString() + ".", VESPA_STRLOC);
}
}
diff --git a/document/src/vespa/document/update/removevalueupdate.cpp b/document/src/vespa/document/update/removevalueupdate.cpp
index 76561e6633c..c21e7c93abe 100644
--- a/document/src/vespa/document/update/removevalueupdate.cpp
+++ b/document/src/vespa/document/update/removevalueupdate.cpp
@@ -7,6 +7,7 @@
#include <vespa/document/serialization/vespadocumentdeserializer.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/document/util/serializableexceptions.h>
+#include <vespa/document/util/bytebuffer.h>
#include <vespa/vespalib/util/xmlstream.h>
using vespalib::IllegalArgumentException;
@@ -23,7 +24,7 @@ RemoveValueUpdate::RemoveValueUpdate(const FieldValue& key)
_key(key.clone())
{}
-RemoveValueUpdate::~RemoveValueUpdate() {}
+RemoveValueUpdate::~RemoveValueUpdate() = default;
bool
RemoveValueUpdate::operator==(const ValueUpdate& other) const
@@ -39,8 +40,7 @@ void
RemoveValueUpdate::checkCompatibility(const Field& field) const
{
if (field.getDataType().inherits(CollectionDataType::classId)) {
- const CollectionDataType& type =
- static_cast<const CollectionDataType&>(field.getDataType());
+ const CollectionDataType& type = static_cast<const CollectionDataType&>(field.getDataType());
if (!type.getNestedType().isValueType(*_key)) {
throw IllegalArgumentException(
"Cannot remove value of type "
@@ -49,9 +49,7 @@ RemoveValueUpdate::checkCompatibility(const Field& field) const
+ field.getDataType().toString(), VESPA_STRLOC);
}
} else {
- throw IllegalArgumentException(
- "Can not remove a value from field of type "
- + field.getDataType().toString(), VESPA_STRLOC);
+ throw IllegalArgumentException("Can not remove a value from field of type " + field.getDataType().toString(), VESPA_STRLOC);
}
}
@@ -66,9 +64,7 @@ RemoveValueUpdate::applyTo(FieldValue& value) const
WeightedSetFieldValue& doc(static_cast<WeightedSetFieldValue&>(value));
doc.remove(*_key);
} else {
- std::string err = vespalib::make_string(
- "Unable to remove a value from a \"%s\" field value.",
- value.getClass().name());
+ std::string err = vespalib::make_string("Unable to remove a value from a \"%s\" field value.", value.getClass().name());
throw IllegalStateException(err, VESPA_STRLOC);
}
return true;
@@ -89,16 +85,13 @@ RemoveValueUpdate::print(std::ostream& out, bool, const std::string&) const
// Deserialize this update from the given buffer.
void
-RemoveValueUpdate::deserialize(
- const DocumentTypeRepo& repo, const DataType& type,
- ByteBuffer& buffer, uint16_t version)
+RemoveValueUpdate::deserialize(const DocumentTypeRepo& repo, const DataType& type, ByteBuffer& buffer, uint16_t version)
{
switch(type.getClass().id()) {
case ArrayDataType::classId:
case WeightedSetDataType::classId:
{
- const CollectionDataType& c(
- static_cast<const CollectionDataType&>(type));
+ const CollectionDataType& c(static_cast<const CollectionDataType&>(type));
_key.reset(c.getNestedType().createFieldValue().release());
nbostream stream(buffer.getBufferAtPos(), buffer.getRemaining());
VespaDocumentDeserializer deserializer(repo, stream, version);
@@ -107,9 +100,7 @@ RemoveValueUpdate::deserialize(
break;
}
default:
- throw DeserializeException(
- "Can not perform remove operation on type "
- + type.toString() + ".", VESPA_STRLOC);
+ throw DeserializeException("Can not perform remove operation on type " + type.toString() + ".", VESPA_STRLOC);
}
}
diff --git a/document/src/vespa/document/update/valueupdate.cpp b/document/src/vespa/document/update/valueupdate.cpp
index d44b1e2e0e5..103d9341f0e 100644
--- a/document/src/vespa/document/update/valueupdate.cpp
+++ b/document/src/vespa/document/update/valueupdate.cpp
@@ -2,6 +2,7 @@
#include "valueupdate.h"
#include <vespa/vespalib/util/stringfmt.h>
+#include <vespa/document/util/bytebuffer.h>
#include <stdexcept>
namespace document {
@@ -10,9 +11,7 @@ IMPLEMENT_IDENTIFIABLE_ABSTRACT(ValueUpdate, Identifiable);
// Create a value update from a byte buffer.
std::unique_ptr<ValueUpdate>
-ValueUpdate::createInstance(const DocumentTypeRepo& repo,
- const DataType& type, ByteBuffer& buffer,
- int serializationVersion)
+ValueUpdate::createInstance(const DocumentTypeRepo& repo, const DataType& type, ByteBuffer& buffer, int serializationVersion)
{
ValueUpdate* update(NULL);
int32_t classId = 0;
diff --git a/document/src/vespa/document/update/valueupdate.h b/document/src/vespa/document/update/valueupdate.h
index 25824799942..ffa40b1c191 100644
--- a/document/src/vespa/document/update/valueupdate.h
+++ b/document/src/vespa/document/update/valueupdate.h
@@ -19,11 +19,8 @@
#pragma once
#include "updatevisitor.h"
-
#include <vespa/document/datatype/datatype.h>
-#include <vespa/document/util/serializable.h>
#include <vespa/document/util/xmlserializable.h>
-#include <vespa/vespalib/objects/cloneable.h>
namespace document {
diff --git a/document/src/vespa/document/util/printable.h b/document/src/vespa/document/util/printable.h
index 0771a6c04e5..71b93d4bdc4 100644
--- a/document/src/vespa/document/util/printable.h
+++ b/document/src/vespa/document/util/printable.h
@@ -16,8 +16,7 @@
#include <iosfwd>
#include <string>
-namespace document
-{
+namespace document {
class Printable {
public:
@@ -48,9 +47,7 @@ public:
* @param indent This indentation should be printed AFTER each newline
* printed. (Not before output in first line)
*/
- virtual void print(std::ostream& out,
- bool verbose,
- const std::string& indent) const = 0;
+ virtual void print(std::ostream& out, bool verbose, const std::string& indent) const = 0;
/**
* Utility function, since default arguments used in virtual functions is
@@ -61,8 +58,7 @@ public:
void print(std::ostream& out, const std::string& indent) const;
/** Utility function to get this output as a string. */
- std::string toString(bool verbose=false,
- const std::string& indent="") const;
+ std::string toString(bool verbose=false, const std::string& indent="") const;
};
std::ostream& operator<<(std::ostream& out, const Printable& p);
diff --git a/document/src/vespa/document/util/serializable.cpp b/document/src/vespa/document/util/serializable.cpp
index 99f7d4943ff..32c7bef90f0 100644
--- a/document/src/vespa/document/util/serializable.cpp
+++ b/document/src/vespa/document/util/serializable.cpp
@@ -68,18 +68,4 @@ Deserializable::deserialize(const DocumentTypeRepo &repo, ByteBuffer& buffer) {
throw;
}
}
-void
-VersionedDeserializable::deserialize(ByteBuffer& buffer, uint16_t version) {
- int pos = buffer.getPos();
- try{
- onDeserialize(buffer, version);
- } catch (const DeserializeException &) {
- buffer.setPos(pos);
- throw;
- } catch (const BufferOutOfBoundsException &) {
- buffer.setPos(pos);
- throw;
- }
-}
-
}
diff --git a/document/src/vespa/document/util/serializable.h b/document/src/vespa/document/util/serializable.h
index 1a9c7f26894..8818feceb9a 100644
--- a/document/src/vespa/document/util/serializable.h
+++ b/document/src/vespa/document/util/serializable.h
@@ -94,37 +94,5 @@ public:
void deserialize(const DocumentTypeRepo &repo, ByteBuffer& buffer);
};
-/**
- * If a deserializable needs a version number of the bytestream to deserialize,
- * and they doesn't include this version number in their own bytestream, they
- * can be VersionedDeserializable, getting version number externally.
- *
- * This is a special case used since document now uses this approach to
- * deserialize its contents. It is preferable to let each component store its
- * own version number, unless this has a big impact on the size of what is
- * serialized.
- */
-class VersionedDeserializable
-{
-protected:
- virtual void onDeserialize(ByteBuffer& buffer, uint16_t version) = 0;
-
-public:
- virtual ~VersionedDeserializable() {}
-
- /**
- * Overwrite this object with the object represented by the given
- * bytestream. On success, buffer will be positioned after the bytestream
- * representing the instance we've just deserialized, on failure, bytebuffer
- * will be pointing to where it was pointing before calling this function.
- *
- * @throw DeserializeException If read data doesn't represent a legal object
- * of this type.
- * @throw BufferOutOfBoundsException If instance wants to read more data
- * than is available in the buffer.
- */
- void deserialize(ByteBuffer& buffer, uint16_t version);
-};
-
}