aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/posting_list_traverser.h
blob: 4fe2b4ff74832ac02fe0f4b4caa45adbf4d82989 (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
// Copyright Yahoo. 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 PostingList>
class PostingListTraverser
{
    using EntryRef = vespalib::datastore::EntryRef;
    const PostingList &_postingList;
    EntryRef _pidx;
public:
    PostingListTraverser(const PostingList &postingList, EntryRef pidx)
        : _postingList(postingList),
          _pidx(pidx)
    {
    }
    ~PostingListTraverser() { }

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

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

}