aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/fast_access_feed_view.cpp
blob: d5fcd0a4f076aa3555cf41cb32d4be99d6cc1126 (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "fast_access_feed_view.h"
#include "forcecommitcontext.h"
#include "operationdonecontext.h"
#include "removedonecontext.h"
#include "putdonecontext.h"
#include <vespa/searchcore/proton/feedoperation/operations.h>

using document::Document;
using document::DocumentUpdate;
using search::index::Schema;

namespace proton {

/**
 * NOTE: For both put, update and remove we only need to pass the 'onWriteDone'
 * instance when we are going to commit as part of handling the operation.
 * Otherwise we can drop it and ack the operation right away.
 */
void
FastAccessFeedView::putAttributes(SerialNum serialNum, search::DocumentIdT lid, const Document &doc, OnPutDoneType onWriteDone)
{
    _attributeWriter->put(serialNum, doc, lid, onWriteDone);
}

void
FastAccessFeedView::updateAttributes(SerialNum serialNum, search::DocumentIdT lid, const DocumentUpdate &upd,
                                     OnOperationDoneType onWriteDone, IFieldUpdateCallback & onUpdate)
{
    _attributeWriter->update(serialNum, upd, lid, onWriteDone, onUpdate);
}

void
FastAccessFeedView::updateAttributes(SerialNum serialNum, Lid lid, FutureDoc futureDoc, OnOperationDoneType onWriteDone)
{
    if (_attributeWriter->hasStructFieldAttribute()) {
        const std::unique_ptr<const Document> & doc = futureDoc.get();
        if (doc) {
            _attributeWriter->update(serialNum, *doc, lid, onWriteDone);
        }
    }
}

void
FastAccessFeedView::removeAttributes(SerialNum serialNum, search::DocumentIdT lid, OnRemoveDoneType onWriteDone)
{
    _attributeWriter->remove(serialNum, lid, onWriteDone);
}

void
FastAccessFeedView::removeAttributes(SerialNum serialNum, const LidVector &lidsToRemove, OnWriteDoneType onWriteDone)
{
    _attributeWriter->remove(lidsToRemove, serialNum, onWriteDone);
}

void
FastAccessFeedView::heartBeatAttributes(SerialNum serialNum, DoneCallback onDone)
{
    _attributeWriter->heartBeat(serialNum, onDone);
}

FastAccessFeedView::FastAccessFeedView(StoreOnlyFeedView::Context storeOnlyCtx, const PersistentParams &params, const Context &ctx)
    : Parent(std::move(storeOnlyCtx), params),
      _attributeWriter(ctx._attrWriter),
      _docIdLimit(ctx._docIdLimit)
{}

FastAccessFeedView::~FastAccessFeedView() = default;

void
FastAccessFeedView::handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone)
{
    // Drain pending PutDoneContext and ForceCommitContext objects
    forceCommitAndWait(search::CommitParam(op.getSerialNum()));
    _docIdLimit.set(op.getLidLimit());
    getAttributeWriter()->compactLidSpace(op.getLidLimit(), op.getSerialNum());
    Parent::handleCompactLidSpace(op, onDone);
}

void
FastAccessFeedView::internalForceCommit(const CommitParam & param, OnForceCommitDoneType onCommitDone)
{
    _attributeWriter->forceCommit(param, onCommitDone);
    onCommitDone->registerCommittedDocIdLimit(_metaStore.getCommittedDocIdLimit(), &_docIdLimit);
    Parent::internalForceCommit(param, onCommitDone);
}

} // namespace proton