aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/server/ifeedview.h
blob: 946d3a9f2f1c07d55445bb8eeb96de05e5bbbbd9 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchcore/proton/common/feedtoken.h>
#include <vespa/searchlib/common/commit_param.h>

namespace document { class DocumentTypeRepo; }

namespace vespalib { class IDestructorCallback; }

namespace proton {

class CompactLidSpaceOperation;
class DeleteBucketOperation;
struct ISimpleDocumentMetaStore;
class MoveOperation;
class PruneRemovedDocumentsOperation;
class PutOperation;
class RemoveOperation;
class UpdateOperation;

/**
 * Interface for a feed view as seen from a feed handler.
 */
class IFeedView
{
protected:
    IFeedView() = default;
public:
    using SP = std::shared_ptr<IFeedView>;
    using DoneCallback = const std::shared_ptr<vespalib::IDestructorCallback> &;
    using IDestructorCallbackSP = std::shared_ptr<vespalib::IDestructorCallback>;
    using CommitParam = search::CommitParam;

    IFeedView(const IFeedView &) = delete;
    IFeedView & operator = (const IFeedView &) = delete;
    virtual ~IFeedView() = default;

    virtual const std::shared_ptr<const document::DocumentTypeRepo> &getDocumentTypeRepo() const = 0;

    /**
     * Access to const version of document meta store.
     * Should only be used by the writer thread.
     */
    virtual const ISimpleDocumentMetaStore * getDocumentMetaStorePtr() const = 0;

    /**
     * Similar to IPersistenceHandler functions.
     */

    virtual void preparePut(PutOperation &putOp) = 0;
    virtual void handlePut(FeedToken token, const PutOperation &putOp) = 0;
    virtual void prepareUpdate(UpdateOperation &updOp) = 0;
    virtual void handleUpdate(FeedToken token, const UpdateOperation &updOp) = 0;
    virtual void prepareRemove(RemoveOperation &rmOp) = 0;
    virtual void handleRemove(FeedToken token, const RemoveOperation &rmOp) = 0;
    virtual void prepareDeleteBucket(DeleteBucketOperation &delOp) = 0;
    virtual void prepareMove(MoveOperation &putOp) = 0;
    virtual void handleDeleteBucket(const DeleteBucketOperation &delOp, DoneCallback onDone) = 0;
    virtual void handleMove(const MoveOperation &putOp, DoneCallback onDone) = 0;
    virtual void heartBeat(search::SerialNum serialNum, DoneCallback onDone) = 0;
    virtual void forceCommit(const CommitParam & param, DoneCallback onDone) = 0;
    virtual void handlePruneRemovedDocuments(const PruneRemovedDocumentsOperation & pruneOp, DoneCallback onDone) = 0;
    virtual void handleCompactLidSpace(const CompactLidSpaceOperation &op, DoneCallback onDone) = 0;
    void forceCommit(CommitParam param) { forceCommit(param, IDestructorCallbackSP()); }
    void forceCommit(search::SerialNum serialNum) { forceCommit(CommitParam(serialNum)); }
    void forceCommitAndWait(CommitParam param);
};

} // namespace proton