aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/test/memoryindex/ordered_field_index_inserter_backend.h
blob: e81b6db5c366f42d2ccb208fe910f7512f2f3070 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/stllike/string.h>
#include <sstream>

namespace search::index { class DocIdAndFeatures; }

namespace search::memoryindex::test {

/*
 * Backend for test version of ordered field index inserter that creates
 * a string representation used to validate correct use of ordered field index inserter.
 */
class OrderedFieldIndexInserterBackend {
    std::stringstream _ss;
    bool _first;
    bool _verbose;
    bool _show_interleaved_features;
    void addComma();
public:
    OrderedFieldIndexInserterBackend();
    ~OrderedFieldIndexInserterBackend();
    void setNextWord(const vespalib::stringref word);
    void add(uint32_t docId, const index::DocIdAndFeatures &features);
    void remove(uint32_t docId);
    void rewind(uint32_t field_id);
    std::string toStr() const;
    void reset();
    void setVerbose() { _verbose = true; }
    void set_show_interleaved_features() { _show_interleaved_features = true; }
};

}