summaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/engine/docsumreply.h
blob: 9e9acd0e49830be84a8367f87fe310fbe7727d1b (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vector>
#include <vespa/document/base/globalid.h>
#include <vespa/vespalib/util/memory.h>
#include <memory>
#include <vespa/searchlib/engine/docsumrequest.h>

namespace vespalib { class Slime; }
namespace search::engine {

struct DocsumReply
{
    using UP = std::unique_ptr<DocsumReply>;

    using Blob = vespalib::MallocPtr;

    struct Docsum {
        document::GlobalId gid;
        Blob     data;

        Docsum() noexcept : gid(), data(0) {}
        Docsum(document::GlobalId gid_) noexcept : gid(gid_), data(0) { }
        Docsum(document::GlobalId gid_, const char *buf, uint32_t len) noexcept : gid(gid_), data(len) {
            memcpy(data.str(), buf, len);
        }
        Docsum & setData(const char *buf, uint32_t len) {
            data.resize(len);
            memcpy(data.str(), buf, len);
            return *this;
        }
    };
    std::vector<Docsum> docsums;

    mutable DocsumRequest::UP request;
    std::unique_ptr<vespalib::Slime> _root;

    DocsumReply();
    DocsumReply(std::unique_ptr<vespalib::Slime> root);
    ~DocsumReply();
};

}