summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-08-20 18:27:44 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-08-21 20:27:38 +0000
commite931d5321e5717a2d6ecca32a0b8880e0e29caa3 (patch)
treecbc1c88a6e148c452ada02eb481b925e5f2bf4e8 /document
parentc389cb6654969771e2b3d41790499ec21b09c905 (diff)
Remove v6/v7 on c++ side too
Diffstat (limited to 'document')
-rw-r--r--document/src/tests/documentupdatetestcase.cpp17
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.cpp2
-rw-r--r--document/src/vespa/document/serialization/vespadocumentdeserializer.cpp76
-rw-r--r--document/src/vespa/document/serialization/vespadocumentserializer.cpp3
-rw-r--r--document/src/vespa/document/update/documentupdate.cpp72
-rw-r--r--document/src/vespa/document/update/documentupdate.h9
6 files changed, 23 insertions, 156 deletions
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp
index b22edfd1ad6..88795041951 100644
--- a/document/src/tests/documentupdatetestcase.cpp
+++ b/document/src/tests/documentupdatetestcase.cpp
@@ -471,7 +471,7 @@ TEST(DocumentUpdateTest, testReadSerializedFile)
auto buf = readBufferFromFile("data/serializeupdatejava.dat");
nbostream is(buf->getBufferAtPos(), buf->getRemaining());
- DocumentUpdate::UP updp(DocumentUpdate::create42(repo, is));
+ DocumentUpdate::UP updp(DocumentUpdate::createHEAD(repo, is));
DocumentUpdate& upd(*updp);
const DocumentType *type = repo.getDocumentType("serializetest");
@@ -1187,7 +1187,7 @@ CreateIfNonExistentFixture::CreateIfNonExistentFixture()
update->setCreateIfNonExistent(true);
}
-TEST(DocumentUpdateTest, testThatCreateIfNonExistentFlagIsSerialized50AndDeserialized50)
+TEST(DocumentUpdateTest, testThatCreateIfNonExistentFlagIsSerializedAndDeserialized)
{
CreateIfNonExistentFixture f;
@@ -1199,19 +1199,6 @@ TEST(DocumentUpdateTest, testThatCreateIfNonExistentFlagIsSerialized50AndDeseria
EXPECT_TRUE(deserialized->getCreateIfNonExistent());
}
-TEST(DocumentUpdateTest, testThatCreateIfNonExistentFlagIsSerializedAndDeserialized)
-{
- CreateIfNonExistentFixture f;
-
- ByteBuffer::UP buf(serialize42(*f.update));
- buf->flip();
-
- nbostream is(buf->getBufferAtPos(), buf->getRemaining());
- auto deserialized = DocumentUpdate::create42(f.docMan.getTypeRepo(), is);
- EXPECT_EQ(*f.update, *deserialized);
- EXPECT_TRUE(deserialized->getCreateIfNonExistent());
-}
-
struct ArrayUpdateFixture {
TestDocMan doc_man;
std::unique_ptr<Document> doc;
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
index 078e4d0ec21..80b86997122 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
@@ -96,7 +96,7 @@ StructFieldValue::lazyDeserialize(const FixedTypeRepo &repo,
_doc_type = &repo.getDocumentType();
_version = version;
- _chunks.push_back(SerializableArray::UP(new SerializableArray()));
+ _chunks.push_back(std::make_unique<SerializableArray>());
_chunks.back().assign(fm, std::move(buffer), comp_type, uncompressed_length);
_hasChanged = false;
}
diff --git a/document/src/vespa/document/serialization/vespadocumentdeserializer.cpp b/document/src/vespa/document/serialization/vespadocumentdeserializer.cpp
index 89172b0bc46..a0eaa9d8154 100644
--- a/document/src/vespa/document/serialization/vespadocumentdeserializer.cpp
+++ b/document/src/vespa/document/serialization/vespadocumentdeserializer.cpp
@@ -46,20 +46,8 @@ namespace document {
namespace {
template <typename Input>
-uint32_t readSize(Input &input, uint16_t version) {
- if (version < 7) {
- readValue<uint32_t>(input); // type id
- return readValue<uint32_t>(input);
- } else {
+uint32_t readSize(Input &input) {
return getInt1_2_4Bytes(input);
- }
-}
-
-template <typename T, typename Input>
-void skipIfOld(Input &input, uint16_t version) {
- if (version < 7) {
- readValue<T>(input);
- }
}
uint32_t
@@ -138,31 +126,24 @@ void VespaDocumentDeserializer::read(Document &value) {
uint16_t version = readValue<uint16_t>(_stream);
VarScope<uint16_t> version_scope(_version, version);
- if (version < 6 || version > 8) {
+ if (version < 8 || version > 8) {
asciistream msg;
msg << "Unrecognized serialization version " << version;
throw DeserializeException(msg.str(), VESPA_STRLOC);
}
- if (version >= 7) {
- uint32_t data_size = readValue<uint32_t>(_stream);
- size_t data_start_size = _stream.size();
- readDocument(value);
- if (version == 7) {
- readValue<uint32_t>(_stream); // Skip crc value.
- }
- if (data_start_size - _stream.size() != data_size) {
- asciistream msg;
- msg << "Length mismatch. Was "
- << data_start_size - _stream.size()
- << ", expected " << data_size << ".";
- throw DeserializeException(msg.str(), VESPA_STRLOC);
- }
- } else { // version <= 6
- getInt2_4_8Bytes(_stream); // skip document length
- readDocument(value);
- readValue<uint32_t>(_stream); // Skip crc value.
+ uint32_t data_size = readValue<uint32_t>(_stream);
+ size_t data_start_size = _stream.size();
+ readDocument(value);
+
+ if (data_start_size - _stream.size() != data_size) {
+ asciistream msg;
+ msg << "Length mismatch. Was "
+ << data_start_size - _stream.size()
+ << ", expected " << data_size << ".";
+ throw DeserializeException(msg.str(), VESPA_STRLOC);
}
+
}
void VespaDocumentDeserializer::read(AnnotationReferenceFieldValue &value) {
@@ -170,21 +151,19 @@ void VespaDocumentDeserializer::read(AnnotationReferenceFieldValue &value) {
}
void VespaDocumentDeserializer::read(ArrayFieldValue &value) {
- uint32_t size = readSize(_stream, _version);
+ uint32_t size = readSize(_stream);
value.clear();
value.resize(size);
for (uint32_t i = 0; i < size; ++i) {
- skipIfOld<uint32_t>(_stream, _version); // element size
value[i].accept(*this); // Double dispatch to call the correct read()
}
}
void VespaDocumentDeserializer::read(MapFieldValue &value) {
value.clear();
- uint32_t size = readSize(_stream, _version);
+ uint32_t size = readSize(_stream);
value.resize(size);
for (auto & pair : value) {
- skipIfOld<uint32_t>(_stream, _version); // element size
pair.first->accept(*this); // Double dispatch to call the correct read()
pair.second->accept(*this); // Double dispatch to call the correct read()
}
@@ -205,14 +184,6 @@ void readFieldValue(nbostream &input, T &value) {
value.setValue(val);
}
-template <typename Input>
-stringref readAttributeString(Input &input) {
- uint8_t size;
- input >> size;
- stringref s(input.peek(), size);
- input.adjustReadPos(size + 1);
- return s;
-}
} // namespace
void VespaDocumentDeserializer::read(BoolFieldValue &value) {
@@ -313,18 +284,9 @@ void readFieldInfo(nbostream& input, SerializableArray::EntryMap & field_info) {
} // namespace
void VespaDocumentDeserializer::readStructNoReset(StructFieldValue &value) {
- size_t start_size = _stream.size();
- size_t data_size;
- if (_version < 6) {
- throw DeserializeException("Illegal struct serialization version.", VESPA_STRLOC);
- } else if (_version < 7) {
- data_size = getInt2_4_8Bytes(_stream);
- } else {
- data_size = readValue<uint32_t>(_stream);
- }
+ size_t data_size = readValue<uint32_t>(_stream);
- CompressionConfig::Type compression_type =
- CompressionConfig::Type(readValue<uint8_t>(_stream));
+ CompressionConfig::Type compression_type = CompressionConfig::Type(readValue<uint8_t>(_stream));
SerializableArray::EntryMap field_info;
size_t uncompressed_size = 0;
@@ -332,9 +294,7 @@ void VespaDocumentDeserializer::readStructNoReset(StructFieldValue &value) {
uncompressed_size = getInt2_4_8Bytes(_stream);
}
readFieldInfo(_stream, field_info);
- if (_version < 7) {
- data_size -= (start_size - _stream.size());
- }
+
if (CompressionConfig::isCompressed(compression_type)) {
if ((compression_type != CompressionConfig::LZ4)) {
throw DeserializeException("Unsupported compression type.", VESPA_STRLOC);
diff --git a/document/src/vespa/document/serialization/vespadocumentserializer.cpp b/document/src/vespa/document/serialization/vespadocumentserializer.cpp
index 0d6703b4e97..9a2e6a89f80 100644
--- a/document/src/vespa/document/serialization/vespadocumentserializer.cpp
+++ b/document/src/vespa/document/serialization/vespadocumentserializer.cpp
@@ -100,8 +100,7 @@ static inline size_t wantChunks(bool hasHeader, bool hasBody) {
return res;
}
-void VespaDocumentSerializer::write(const Document &value,
- DocSerializationMode mode) {
+void VespaDocumentSerializer::write(const Document &value, DocSerializationMode mode) {
nbostream doc_stream;
VespaDocumentSerializer doc_serializer(doc_stream);
doc_serializer.write(value.getId());
diff --git a/document/src/vespa/document/update/documentupdate.cpp b/document/src/vespa/document/update/documentupdate.cpp
index f2b8d40e0a3..c7cf710958d 100644
--- a/document/src/vespa/document/update/documentupdate.cpp
+++ b/document/src/vespa/document/update/documentupdate.cpp
@@ -35,32 +35,6 @@ readCStr(nbostream & stream) {
return vespalib::stringref(s, sz);
}
-std::pair<const DocumentType *, DocumentId>
-deserializeTypeAndId(const DocumentTypeRepo& repo, vespalib::nbostream & stream) {
- DocumentId docId(readCStr(stream));
-
- // Read content bit vector.
- unsigned char content = 0x00;
- stream >> content;
-
- // Why on earth do we have this whether we have type part?
- // We need type for object to work, so just throwing exception if it's
- // not there.
- if((content & CONTENT_HASTYPE) == 0) {
- throw IllegalStateException("Missing document type", VESPA_STRLOC);
- }
-
- vespalib::stringref typestr = readCStr(stream);
-
- int16_t version = 0;
- stream >> version;
- const DocumentType *type = repo.getDocumentType(typestr);
- if (!type) {
- throw DocumentTypeNotFoundException(typestr, VESPA_STRLOC);
- }
- return std::make_pair(type, docId);
-}
-
const DocumentType *
deserializeHeader(const DocumentTypeRepo &repo, vespalib::nbostream & stream, vespalib::stringref & documentId)
{
@@ -258,15 +232,6 @@ DocumentUpdate::serializeFlags(int size_) const
return flags.injectInto(size_);
}
-// Deserialize the content of the given buffer into this document update.
-DocumentUpdate::UP
-DocumentUpdate::create42(const DocumentTypeRepo& repo, vespalib::nbostream & stream)
-{
- auto update = std::make_unique<DocumentUpdate>();
- update->init42(repo, stream);
- return update;
-}
-
DocumentUpdate::UP
DocumentUpdate::createHEAD(const DocumentTypeRepo& repo, ByteBuffer& buffer)
{
@@ -285,13 +250,7 @@ DocumentUpdate::createHEAD(const DocumentTypeRepo& repo, vespalib::nbostream str
return update;
}
-void
-DocumentUpdate::init42(const DocumentTypeRepo & repo, vespalib::nbostream & stream)
-{
- _repo = &repo;
- deserialize42(repo, stream);
- reserialize();
-}
+
void
DocumentUpdate::initHEAD(const DocumentTypeRepo & repo, vespalib::nbostream && stream)
{
@@ -317,35 +276,6 @@ DocumentUpdate::initHEAD(const DocumentTypeRepo & repo, vespalib::nbostream & st
}
void
-DocumentUpdate::deserialize42(const DocumentTypeRepo& repo, vespalib::nbostream & stream)
-{
- size_t pos = stream.rp();
- try{
- int16_t version(0);
- stream >> version;
- std::pair<const DocumentType *, DocumentId> typeAndId(deserializeTypeAndId(repo, stream));
- _type = typeAndId.first;
- _documentId = typeAndId.second;
- // Read field updates, if any.
- if (! stream.empty()) {
- int32_t sizeAndFlags = 0;
- stream >> sizeAndFlags;
- int numUpdates = deserializeFlags(sizeAndFlags);
- _updates.reserve(numUpdates);
- for (int i = 0; i < numUpdates; i++) {
- _updates.emplace_back(repo, *typeAndId.first, stream);
- }
- }
- } catch (const DeserializeException &) {
- stream.rp(pos);
- throw;
- } catch (const BufferOutOfBoundsException &) {
- stream.rp(pos);
- throw;
- }
-}
-
-void
DocumentUpdate::deserializeBody(const DocumentTypeRepo &repo, vespalib::nbostream &stream)
{
_updates.clear();
diff --git a/document/src/vespa/document/update/documentupdate.h b/document/src/vespa/document/update/documentupdate.h
index 902bfe63a0a..a672d028f35 100644
--- a/document/src/vespa/document/update/documentupdate.h
+++ b/document/src/vespa/document/update/documentupdate.h
@@ -48,11 +48,6 @@ public:
typedef std::vector<FieldPathUpdate::CP> FieldPathUpdateV;
/**
- * Create old style document update, no support for field path updates.
- */
- static DocumentUpdate::UP create42(const DocumentTypeRepo & repo, vespalib::nbostream & stream);
-
- /**
* Create new style document update, possibly with field path updates.
*/
static DocumentUpdate::UP createHEAD(const DocumentTypeRepo & repo, vespalib::nbostream stream);
@@ -129,10 +124,8 @@ private:
bool _needHardReserialize;
int deserializeFlags(int sizeAndFlags);
- void init42(const DocumentTypeRepo & repo, vespalib::nbostream & stream);
void initHEAD(const DocumentTypeRepo & repo, vespalib::nbostream && stream);
void initHEAD(const DocumentTypeRepo & repo, vespalib::nbostream & stream);
- void deserialize42(const DocumentTypeRepo & repo, vespalib::nbostream & stream);
void deserializeBody(const DocumentTypeRepo &repo, vespalib::nbostream &stream);
void lazyDeserialize(const DocumentTypeRepo & repo, vespalib::nbostream & stream);
void ensureDeserialized() const;
@@ -143,6 +136,4 @@ private:
std::ostream &operator<<(std::ostream &out, const DocumentUpdate &update);
-
}
-