aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/attribute/enumattributesaver.h
blob: 946ff9fe73bb496d6931a920343e775a3c35b26c (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "i_enum_store.h"
#include <vespa/vespalib/datastore/unique_store_enumerator.h>

namespace search {

class IAttributeSaveTarget;

/**
 * Helper class for saving an enumerated multivalue attribute.
 *
 * It handles writing to the udat file.
 */
class EnumAttributeSaver
{
public:
    using Enumerator = IEnumStore::Enumerator;

private:
    const IEnumStore  &_enumStore;
    std::unique_ptr<Enumerator> _enumerator;

public:
    EnumAttributeSaver(IEnumStore &enumStore);
    ~EnumAttributeSaver();

    void writeUdat(IAttributeSaveTarget &saveTarget);
    const IEnumStore &getEnumStore() const { return _enumStore; }
    Enumerator &get_enumerator() { return *_enumerator; }
    void clear() { _enumerator->clear(); }
};

} // namespace search