1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "moveoperation.h"
#include <vespa/document/fieldvalue/document.h>
#include <cassert>
using document::BucketId;
using document::Document;
using document::DocumentTypeRepo;
using storage::spi::Timestamp;
using vespalib::make_string;
namespace proton {
MoveOperation::MoveOperation()
: DocumentOperation(FeedOperation::MOVE),
_doc()
{ }
MoveOperation::MoveOperation(const BucketId &bucketId,
Timestamp timestamp,
const Document::SP &doc,
DbDocumentId sourceDbdId,
uint32_t targetSubDbId)
: DocumentOperation(FeedOperation::MOVE, bucketId, timestamp),
_doc(doc)
{
setPrevDbDocumentId(sourceDbdId);
setDbDocumentId(DbDocumentId(targetSubDbId, 0u));
}
MoveOperation::~MoveOperation() = default;
void
MoveOperation::serialize(vespalib::nbostream &os) const
{
assertValidBucketId(_doc->getId());
assert(movingLidIfInSameSubDb());
DocumentOperation::serialize(os);
size_t oldSize = os.size();
_doc->serialize(os);
_serializedDocSize = os.size() - oldSize;
}
void
MoveOperation::deserialize(vespalib::nbostream &is,
const DocumentTypeRepo &repo)
{
DocumentOperation::deserialize(is, repo);
size_t oldSize = is.size();
_doc.reset(new Document(repo, is));
_serializedDocSize = oldSize - is.size();
}
vespalib::string MoveOperation::toString() const {
return make_string("Move(%s, %s)",
_doc.get() ?
_doc->getId().getScheme().toString().c_str() : "NULL",
docArgsToString().c_str());
}
} // namespace proton
|