blob: 71c7c93f7561de3800e7d82110ab76489235b795 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/searchcommon/common/schema.h>
#include <vespa/searchlib/memoryindex/field_index.h>
#include <vespa/searchlib/test/memoryindex/wrap_inserter.h>
#include <vespa/searchlib/test/searchiteratorverifier.h>
#include <vespa/searchlib/fef/termfieldmatchdataarray.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/log/log.h>
LOG_SETUP("field_index_iterator_test");
using namespace search::fef;
using namespace search::index;
using namespace search::memoryindex::test;
using namespace search::memoryindex;
using search::index::schema::DataType;
using search::test::SearchIteratorVerifier;
template <typename FieldIndexType>
class Verifier : public SearchIteratorVerifier {
private:
mutable TermFieldMatchData _tfmd;
FieldIndexType _field_index;
public:
Verifier(const Schema& schema)
: _tfmd(),
_field_index(schema, 0)
{
WrapInserter inserter(_field_index);
inserter.word("a");
for (uint32_t docId : getExpectedDocIds()) {
inserter.add(docId);
}
inserter.flush();
}
~Verifier() {}
SearchIterator::UP create(bool strict) const override {
(void) strict;
TermFieldMatchDataArray match_data;
match_data.add(&_tfmd);
return _field_index.make_search_iterator("a", 0, match_data);
}
};
Schema
get_schema()
{
Schema result;
result.addIndexField(Schema::IndexField("f0", DataType::STRING));
return result;
}
template <typename FieldIndexType>
struct Fixture {
Schema schema;
Verifier<FieldIndexType> verifier;
Fixture()
: schema(get_schema()),
verifier(schema)
{
}
};
TEST_F("require that normal posting iterator conforms", Fixture<FieldIndex<false>>)
{
f.verifier.verify();
}
TEST_F("require that interleaved posting iterator conforms", Fixture<FieldIndex<true>>)
{
f.verifier.verify();
}
TEST_MAIN() { TEST_RUN_ALL(); }
|