aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/aggregation/vdshit.h
blob: 11cfe9b3b1833a8707c894b3e0d8a4afd9364d0f (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "hit.h"
#include "aggregationresult.h"

namespace search::aggregation {

class VdsHit : public Hit
{
public:
    using Summary = std::vector<uint8_t>;
    using DocId = vespalib::string;
    DECLARE_IDENTIFIABLE_NS2(search, aggregation, VdsHit);
    DECLARE_NBO_SERIALIZE;
    VdsHit() noexcept : Hit(), _docId(), _summary() {}
    VdsHit(DocId docId, HitRank rank) noexcept : Hit(rank), _docId(docId), _summary() {}
    ~VdsHit();
    VdsHit *clone() const override { return new VdsHit(*this); }
    void visitMembers(vespalib::ObjectVisitor &visitor) const override;
    const   DocId &   getDocId() const noexcept { return _docId; }
    const Summary & getSummary() const noexcept { return _summary; }
    VdsHit &   setDocId(DocId & docId) noexcept { _docId = docId; return *this; }
    VdsHit & setSummary(const void * buf, size_t sz) noexcept {
        const uint8_t * v(static_cast<const uint8_t *>(buf));
        Summary n(v, v+sz);
        _summary.swap(n);
        return *this;
    }
    bool operator < (const VdsHit &b) const noexcept { return cmp(b) < 0; }

private:
    DocId     _docId;
    Summary   _summary;
};

}