summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
Diffstat (limited to 'document')
-rw-r--r--document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java2
-rw-r--r--document/src/tests/fieldpathupdatetestcase.cpp44
-rw-r--r--document/src/tests/serialization/vespadocumentserializer_test.cpp2
-rw-r--r--document/src/vespa/document/base/field.h2
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.cpp14
-rw-r--r--document/src/vespa/document/repo/fixedtyperepo.h4
-rw-r--r--document/src/vespa/document/util/bytebuffer.cpp4
7 files changed, 53 insertions, 19 deletions
diff --git a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
index ab4af5e722e..675ad502630 100644
--- a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
+++ b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
@@ -1757,7 +1757,7 @@ public class JsonReaderTestCase {
@Test
public void tensor_add_update_on_not_fully_specified_cell_throws() {
- illegalTensorAddUpdate("Error in 'sparse_tensor': Missing a label for dimension y for tensor(x{},y{})",
+ illegalTensorAddUpdate("Error in 'sparse_tensor': Missing a label for dimension 'y' for tensor(x{},y{})",
"sparse_tensor",
"{",
" 'cells': [",
diff --git a/document/src/tests/fieldpathupdatetestcase.cpp b/document/src/tests/fieldpathupdatetestcase.cpp
index 89a95c1d62f..a32face5e55 100644
--- a/document/src/tests/fieldpathupdatetestcase.cpp
+++ b/document/src/tests/fieldpathupdatetestcase.cpp
@@ -134,6 +134,7 @@ FieldPathUpdateTestCase::TearDown()
TEST_F(FieldPathUpdateTestCase, testRemoveField)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::things:thangs"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strfoo") == false);
doc->setValue("strfoo", StringFieldValue("cocacola"));
EXPECT_EQ(vespalib::string("cocacola"), doc->getValue("strfoo")->getAsString());
@@ -195,6 +196,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiList2)
TEST_F(FieldPathUpdateTestCase, testApplyRemoveEntireListField)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::things:thangs"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strarray") == false);
{
ArrayFieldValue strArray(doc->getType().getField("strarray").getDataType());
@@ -213,6 +215,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveEntireListField)
TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiWset)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::helan:halvan"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strwset") == false);
{
WeightedSetFieldValue strWset(doc->getType().getField("strwset").getDataType());
@@ -235,6 +238,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyRemoveMultiWset)
TEST_F(FieldPathUpdateTestCase, testApplyAssignSingle)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::drekka:karsk"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strfoo") == false);
// Test assignment of non-existing
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -252,6 +256,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignSingle)
TEST_F(FieldPathUpdateTestCase, testApplyAssignMath)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::bat:man"));
+ doc->setRepo(*_repo);
doc->setValue("num", IntFieldValue(34));
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -263,6 +268,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMath)
TEST_F(FieldPathUpdateTestCase, testApplyAssignMathByteToZero)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::bat:man"));
+ doc->setRepo(*_repo);
doc->setValue("byteval", ByteFieldValue(3));
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -275,6 +281,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMathNotModifiedOnUnderflow)
{
int low_value = -126;
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::bat:man"));
+ doc->setRepo(*_repo);
doc->setValue("byteval", ByteFieldValue(low_value));
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -287,6 +294,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMathNotModifiedOnUnderflow)
TEST_F(FieldPathUpdateTestCase, testApplyAssignMathNotModifiedOnOverflow)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::bat:man"));
+ doc->setRepo(*_repo);
doc->setValue("byteval", ByteFieldValue(127));
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -299,6 +307,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMathNotModifiedOnOverflow)
TEST_F(FieldPathUpdateTestCase, testApplyAssignMathDivZero)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::bat:man"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("num") == false);
doc->setValue("num", IntFieldValue(10));
@@ -338,6 +347,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignFieldNotExistingInPath)
TEST_F(FieldPathUpdateTestCase, testApplyAssignTargetNotExisting)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::bat:man"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("num") == false);
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -376,6 +386,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignSimpleMapValueWithVariable)
TEST_F(FieldPathUpdateTestCase, testApplyAssignMathRemoveIfZero)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::bat:man"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("num") == false);
doc->setValue("num", IntFieldValue(34));
EXPECT_TRUE(doc->hasValue("num") == true);
@@ -392,6 +403,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMathRemoveIfZero)
TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiList)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::fest:skinnvest"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strarray") == false);
{
@@ -421,6 +433,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiList)
TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiWset)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::fest:skinnvest"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strarray") == false);
{
@@ -451,6 +464,7 @@ TEST_F(FieldPathUpdateTestCase, testApplyAssignMultiWset)
TEST_F(FieldPathUpdateTestCase, testAssignWsetRemoveIfZero)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::tronder:bataljon"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strarray") == false);
{
@@ -479,7 +493,8 @@ TEST_F(FieldPathUpdateTestCase, testAssignWsetRemoveIfZero)
TEST_F(FieldPathUpdateTestCase, testApplyAddMultiList)
{
- auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::george:costanza"));
+ auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::george:costanza"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strarray") == false);
auto adds = std::make_unique<ArrayFieldValue>(doc->getType().getField("strarray").getDataType());
@@ -497,7 +512,8 @@ TEST_F(FieldPathUpdateTestCase, testApplyAddMultiList)
TEST_F(FieldPathUpdateTestCase, testAddAndAssignList)
{
- auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::fancy:pants"));
+ auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::fancy:pants"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strarray") == false);
{
@@ -558,11 +574,11 @@ struct Fixture {
return sval;
}
~Fixture();
- Fixture(const DocumentType &doc_type, const Keys &k);
+ Fixture(const DocumentTypeRepo &repo, const DocumentType &doc_type, const Keys &k);
};
Fixture::~Fixture() = default;
-Fixture::Fixture(const DocumentType &doc_type, const Keys &k)
+Fixture::Fixture(const DocumentTypeRepo &repo, const DocumentType &doc_type, const Keys &k)
: _doc_type(&doc_type),
doc(new Document(doc_type, DocumentId("id:ns:" + doc_type.getName() + "::planet:express"))),
mfv(getMapType(doc_type)),
@@ -570,6 +586,8 @@ Fixture::Fixture(const DocumentType &doc_type, const Keys &k)
fv2(getMapType(doc_type).getValueType()),
fv3(getMapType(doc_type).getValueType())
{
+ doc->setRepo(repo);
+
fv1.setValue("title", StringFieldValue("fry"));
fv1.setValue("rating", IntFieldValue(30));
mfv.put(StringFieldValue(k.key1), fv1);
@@ -590,7 +608,7 @@ Fixture::Fixture(const DocumentType &doc_type, const Keys &k)
TEST_F(FieldPathUpdateTestCase, testAssignMap)
{
Keys k;
- Fixture f(*_foobar_type, k);
+ Fixture f(*_repo, *_foobar_type, k);
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
docUp.addFieldPathUpdate(std::make_unique<AssignFieldPathUpdate>(*f.doc->getDataType(), "structmap{" + k.key2 + "}", std::string(), f.fv4()));
@@ -606,7 +624,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignMap)
TEST_F(FieldPathUpdateTestCase, testAssignMapStruct)
{
Keys k;
- Fixture f(*_foobar_type, k);
+ Fixture f(*_repo, *_foobar_type, k);
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
docUp.addFieldPathUpdate(std::make_unique<AssignFieldPathUpdate>(*f.doc->getDataType(), "structmap{" + k.key2 + "}.rating",
@@ -623,7 +641,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignMapStruct)
TEST_F(FieldPathUpdateTestCase, testAssignMapStructVariable)
{
Keys k;
- Fixture f(*_foobar_type, k);
+ Fixture f(*_repo, *_foobar_type, k);
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
docUp.addFieldPathUpdate(std::make_unique<AssignFieldPathUpdate>(*f.doc->getDataType(), "structmap{$x}.rating",
@@ -648,6 +666,7 @@ createFry(const DataType & type) {
TEST_F(FieldPathUpdateTestCase, testAssignMapNoExist)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::planet:express"));
+ doc->setRepo(*_repo);
MapFieldValue mfv(doc->getType().getField("structmap").getDataType());
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -665,6 +684,7 @@ TEST_F(FieldPathUpdateTestCase, testAssignMapNoExist)
TEST_F(FieldPathUpdateTestCase, testAssignMapNoExistNoCreate)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::planet:express"));
+ doc->setRepo(*_repo);
MapFieldValue mfv(doc->getType().getField("structmap").getDataType());
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -686,7 +706,7 @@ TEST_F(FieldPathUpdateTestCase, testQuotedStringKey)
Keys k;
k.key2 = "here is a \"fancy\" 'map' :-} key :-{";
const char field_path[] = "structmap{\"here is a \\\"fancy\\\" 'map' :-} key :-{\"}";
- Fixture f(*_foobar_type, k);
+ Fixture f(*_repo, *_foobar_type, k);
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
docUp.addFieldPathUpdate(std::make_unique<AssignFieldPathUpdate>(*f.doc->getDataType(), field_path, std::string(), f.fv4()));
@@ -711,6 +731,7 @@ createTastyCake(const DataType &type) {
TEST_F(FieldPathUpdateTestCase, testEqualityComparison)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::foo:zoo"));
+ doc->setRepo(*_repo);
MapFieldValue mfv(doc->getType().getField("structmap").getDataType());
{
@@ -752,6 +773,7 @@ TEST_F(FieldPathUpdateTestCase, testEqualityComparison)
TEST_F(FieldPathUpdateTestCase, testAffectsDocumentBody)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::things:stuff"));
+ doc->setRepo(*_repo);
MapFieldValue mfv(doc->getType().getField("structmap").getDataType());
auto fv4 = std::make_unique<StructFieldValue>(dynamic_cast<const MapDataType&>(*mfv.getDataType()).getValueType());
@@ -780,6 +802,7 @@ TEST_F(FieldPathUpdateTestCase, testAffectsDocumentBody)
TEST_F(FieldPathUpdateTestCase, testIncompatibleDataTypeFails)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::things:stuff"));
+ doc->setRepo(*_repo);
MapFieldValue mfv(doc->getType().getField("structmap").getDataType());
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -795,6 +818,7 @@ TEST_F(FieldPathUpdateTestCase, testIncompatibleDataTypeFails)
TEST_F(FieldPathUpdateTestCase, testSerializeAssign)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::weloveto:serializestuff"));
+ doc->setRepo(*_repo);
MapFieldValue mfv(doc->getType().getField("structmap").getDataType());
auto val = std::make_unique<StructFieldValue>(dynamic_cast<const MapDataType&>(*mfv.getDataType()).getValueType());
@@ -813,6 +837,7 @@ TEST_F(FieldPathUpdateTestCase, testSerializeAssign)
TEST_F(FieldPathUpdateTestCase, testSerializeAdd)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::george:costanza"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("strarray") == false);
auto adds = std::make_unique<ArrayFieldValue>(doc->getType().getField("strarray").getDataType());
@@ -830,6 +855,7 @@ TEST_F(FieldPathUpdateTestCase, testSerializeAdd)
TEST_F(FieldPathUpdateTestCase, testSerializeRemove)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::weloveto:serializestuff"));
+ doc->setRepo(*_repo);
MapFieldValue mfv(doc->getType().getField("structmap").getDataType());
DocumentUpdate docUp(*_repo, *_foobar_type, DocumentId("id:ns:foobar::barbar:foofoo"));
@@ -842,6 +868,7 @@ TEST_F(FieldPathUpdateTestCase, testSerializeRemove)
TEST_F(FieldPathUpdateTestCase, testSerializeAssignMath)
{
auto doc = std::make_unique<Document>(*_foobar_type, DocumentId("id:ns:foobar::bat:man"));
+ doc->setRepo(*_repo);
EXPECT_TRUE(doc->hasValue("num") == false);
doc->setValue("num", IntFieldValue(34));
@@ -933,6 +960,7 @@ TEST_F(FieldPathUpdateTestCase, array_element_update_for_invalid_index_is_ignore
TEST_F(FieldPathUpdateTestCase, update_can_have_removes_for_both_existent_and_nonexistent_keys) {
DocumentId doc_id("id:ns:foobar::george:costanza");
auto doc = std::make_unique<Document>(*_foobar_type, doc_id);
+ doc->setRepo(*_repo);
auto& map_type = dynamic_cast<const MapDataType&>(doc->getType().getField("structmap").getDataType());
auto& struct_type = map_type.getValueType();
MapFieldValue mfv(map_type);
diff --git a/document/src/tests/serialization/vespadocumentserializer_test.cpp b/document/src/tests/serialization/vespadocumentserializer_test.cpp
index 3db001e1732..40d78327ab4 100644
--- a/document/src/tests/serialization/vespadocumentserializer_test.cpp
+++ b/document/src/tests/serialization/vespadocumentserializer_test.cpp
@@ -812,7 +812,7 @@ DocumenttypesConfig getTensorDocTypesConfig() {
const DocumentTypeRepo tensor_doc_repo(getTensorDocTypesConfig());
const FixedTypeRepo tensor_repo(tensor_doc_repo,
- *tensor_doc_repo.getDocumentType(doc_type_id));
+ *tensor_doc_repo.getDocumentType(tensor_doc_type_id));
const DocumentTypeRepo tensor_doc_repo1(getTensorDocTypesConfig("tensor(dimX{})"));
diff --git a/document/src/vespa/document/base/field.h b/document/src/vespa/document/base/field.h
index c80733dd5ff..dea7198015a 100644
--- a/document/src/vespa/document/base/field.h
+++ b/document/src/vespa/document/base/field.h
@@ -56,7 +56,7 @@ public:
bool contains(const Set & field) const;
size_t size() const { return _fields.size(); }
bool empty() const { return _fields.empty(); }
- const CPtr * begin() const { return &_fields[0]; }
+ const CPtr * begin() const { return _fields.data(); }
const CPtr * end() const { return begin() + _fields.size(); }
static Set emptySet() { return Builder().build(); }
private:
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
index 529e608533e..7975dd3a327 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
@@ -50,8 +50,8 @@ StructFieldValue::getStructType() const {
void
StructFieldValue::lazyDeserialize(const FixedTypeRepo &repo, uint16_t version, SerializableArray::EntryMap && fm, ByteBuffer buffer)
{
- _repo = &repo.getDocumentTypeRepo();
- _doc_type = &repo.getDocumentType();
+ _repo = repo.getDocumentTypeRepoPtr();
+ _doc_type = repo.getDocumentTypePtr();
_version = version;
_fields.set(std::move(fm), std::move(buffer));
@@ -117,7 +117,7 @@ StructFieldValue::getField(vespalib::stringref name) const
namespace {
void
-createFV(FieldValue & value, const DocumentTypeRepo & repo, nbostream & stream, const DocumentType & doc_type, uint32_t version)
+createFV(FieldValue & value, const DocumentTypeRepo * repo, nbostream & stream, const DocumentType * doc_type, uint32_t version)
{
FixedTypeRepo frepo(repo, doc_type);
try {
@@ -142,9 +142,9 @@ StructFieldValue::getFieldValue(const Field& field) const
FieldValue::UP value(field.getDataType().createFieldValue());
if ((_repo == nullptr) && (_doc_type != nullptr)) {
DocumentTypeRepo tmpRepo(*_doc_type);
- createFV(*value, tmpRepo, stream, *_doc_type, _version);
+ createFV(*value, &tmpRepo, stream, _doc_type, _version);
} else {
- createFV(*value, *_repo, stream, *_doc_type, _version);
+ createFV(*value, _repo, stream, _doc_type, _version);
}
return value;
}
@@ -172,9 +172,9 @@ StructFieldValue::getFieldValue(const Field& field, FieldValue& value) const
nbostream_longlivedbuf stream(buf.c_str(), buf.size());
if ((_repo == nullptr) && (_doc_type != nullptr)) {
DocumentTypeRepo tmpRepo(*_doc_type);
- createFV(value, tmpRepo, stream, *_doc_type, _version);
+ createFV(value, &tmpRepo, stream, _doc_type, _version);
} else {
- createFV(value, *_repo, stream, *_doc_type, _version);
+ createFV(value, _repo, stream, _doc_type, _version);
}
return true;
}
diff --git a/document/src/vespa/document/repo/fixedtyperepo.h b/document/src/vespa/document/repo/fixedtyperepo.h
index ca37d893718..f1f9230bfd3 100644
--- a/document/src/vespa/document/repo/fixedtyperepo.h
+++ b/document/src/vespa/document/repo/fixedtyperepo.h
@@ -17,6 +17,8 @@ public:
: _repo(&repo), _doc_type(repo.getDefaultDocType()) {}
FixedTypeRepo(const DocumentTypeRepo &repo, const DocumentType &doc_type) noexcept
: _repo(&repo), _doc_type(&doc_type) {}
+ FixedTypeRepo(const DocumentTypeRepo *repo, const DocumentType *doc_type) noexcept
+ : _repo(repo), _doc_type(doc_type) {}
FixedTypeRepo(const DocumentTypeRepo &repo, const vespalib::string &type) noexcept;
const DataType *getDataType(int32_t id) const { return _repo->getDataType(*_doc_type, id); }
@@ -24,6 +26,8 @@ public:
const AnnotationType *getAnnotationType(int32_t id) const { return _repo->getAnnotationType(*_doc_type, id); }
const DocumentTypeRepo &getDocumentTypeRepo() const { return *_repo; }
const DocumentType &getDocumentType() const noexcept { return *_doc_type; }
+ const DocumentTypeRepo *getDocumentTypeRepoPtr() const { return _repo; }
+ const DocumentType *getDocumentTypePtr() const noexcept { return _doc_type; }
};
} // namespace document
diff --git a/document/src/vespa/document/util/bytebuffer.cpp b/document/src/vespa/document/util/bytebuffer.cpp
index 3d38aba6dae..8568ce44c5e 100644
--- a/document/src/vespa/document/util/bytebuffer.cpp
+++ b/document/src/vespa/document/util/bytebuffer.cpp
@@ -164,7 +164,9 @@ void ByteBuffer::getBytes(void *buffer, uint32_t count)
{
const char *v = getBufferAtPos();
incPos(count);
- memcpy(buffer, v, count);
+ if (count > 0) {
+ memcpy(buffer, v, count);
+ }
}
} // document