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

#pragma once

#include <cstdint>
#include <limits>

namespace document { class GlobalId; }

namespace proton::documentmetastore {

/*
 * Class containing lid and the most significant portion of gid according
 * to compare functor (document::GlobalId::BucketOrderCmp).
 */
class GidToLidMapKey {
    uint32_t _lid;
    uint32_t _gid_key;
    static constexpr uint32_t FIND_DOC_ID = std::numeric_limits<uint32_t>::max();

public:
    GidToLidMapKey() noexcept
        : _lid(FIND_DOC_ID),
          _gid_key(0u)
    {
    }
    GidToLidMapKey(uint32_t lid, uint32_t gid_key) noexcept
        : _lid(lid),
          _gid_key(gid_key)
    {
    }
    GidToLidMapKey(uint32_t lid, const document::GlobalId &gid);
    static GidToLidMapKey make_find_key(const document::GlobalId &gid);

    uint32_t get_lid() const { return _lid; }
    uint32_t get_gid_key() const { return _gid_key; }
    bool is_find_key() const { return _lid == FIND_DOC_ID; }
};

}