aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/posting_list_traverser.h
blob: 18b80e1043290664a59381290597397d6793fa7c (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

namespace search::attribute {

/*
 * Class used to traverse a posting list and call the functor for each lid.
 */
template <typename PostingStore>
class PostingListTraverser
{
    using EntryRef = vespalib::datastore::EntryRef;
    const PostingStore &_posting_store;
    EntryRef _pidx;
public:
    PostingListTraverser(const PostingStore &posting_store, EntryRef pidx)
        : _posting_store(posting_store),
          _pidx(pidx)
    {
    }
    ~PostingListTraverser() = default;

    template <typename Func>
    void
    foreach(Func func) const {
        _posting_store.foreach_frozen(_pidx, func);
    }

    template <typename Func>
    void
    foreach_key(Func func) const {
        _posting_store.foreach_frozen_key(_pidx, func);
    }
};

}