aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/memoryindex/field_index
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2019-06-21 13:27:46 +0000
committerGeir Storli <geirst@verizonmedia.com>2019-06-21 13:27:46 +0000
commit4373b26bdbd1f919bc574096e56ce6332bb5c5a3 (patch)
treef2c2235b7d2853cafafefee450cf59a7c72e934b /searchlib/src/tests/memoryindex/field_index
parentbad7460816a4f3e229be227b04c4cbaa27049ed0 (diff)
Instantiate field index type based on config in index schema.
Diffstat (limited to 'searchlib/src/tests/memoryindex/field_index')
-rw-r--r--searchlib/src/tests/memoryindex/field_index/field_index_iterator_test.cpp16
-rw-r--r--searchlib/src/tests/memoryindex/field_index/field_index_test.cpp34
2 files changed, 44 insertions, 6 deletions
diff --git a/searchlib/src/tests/memoryindex/field_index/field_index_iterator_test.cpp b/searchlib/src/tests/memoryindex/field_index/field_index_iterator_test.cpp
index 4658707a1f3..54124326507 100644
--- a/searchlib/src/tests/memoryindex/field_index/field_index_iterator_test.cpp
+++ b/searchlib/src/tests/memoryindex/field_index/field_index_iterator_test.cpp
@@ -18,8 +18,7 @@ using namespace search::memoryindex;
using search::index::schema::DataType;
using search::test::SearchIteratorVerifier;
-using FieldIndexType = FieldIndex<false>;
-
+template <typename FieldIndexType>
class Verifier : public SearchIteratorVerifier {
private:
mutable TermFieldMatchData _tfmd;
@@ -43,8 +42,7 @@ public:
(void) strict;
TermFieldMatchDataArray match_data;
match_data.add(&_tfmd);
- return make_search_iterator<false>(_field_index.find("a"),
- _field_index.getFeatureStore(), 0, match_data);
+ return _field_index.make_search_iterator("a", 0, match_data);
}
};
@@ -56,9 +54,10 @@ get_schema()
return result;
}
+template <typename FieldIndexType>
struct Fixture {
Schema schema;
- Verifier verifier;
+ Verifier<FieldIndexType> verifier;
Fixture()
: schema(get_schema()),
verifier(schema)
@@ -66,7 +65,12 @@ struct Fixture {
}
};
-TEST_F("require that posting iterator conforms", Fixture)
+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();
}
diff --git a/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp b/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp
index ca02573bea2..de3b87194f8 100644
--- a/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp
+++ b/searchlib/src/tests/memoryindex/field_index/field_index_test.cpp
@@ -840,6 +840,40 @@ TEST_F(FieldIndexCollectionTest, require_that_dumping_words_with_no_docs_to_inde
}
}
+
+struct FieldIndexCollectionTypeTest : public ::testing::Test {
+ Schema schema;
+ FieldIndexCollection fic;
+ FieldIndexCollectionTypeTest()
+ : schema(make_schema()),
+ fic(schema, MockFieldLengthInspector())
+ {
+ }
+ Schema make_schema() {
+ Schema result;
+ result.addIndexField(Schema::IndexField("normal", DataType::STRING));
+ Schema::IndexField interleaved("interleaved", DataType::STRING);
+ interleaved.set_experimental_posting_list_format(true);
+ result.addIndexField(interleaved);
+ return result;
+ }
+};
+
+template <typename FieldIndexType>
+void
+expect_field_index_type(const IFieldIndex* field_index)
+{
+ auto* other_type = dynamic_cast<const FieldIndexType*>(field_index);
+ EXPECT_TRUE(other_type != nullptr);
+}
+
+TEST_F(FieldIndexCollectionTypeTest, instantiates_field_index_type_based_on_schema_config)
+{
+ expect_field_index_type<FieldIndex<false>>(fic.getFieldIndex(0));
+ expect_field_index_type<FieldIndex<true>>(fic.getFieldIndex(1));
+}
+
+
class InverterTest : public ::testing::Test {
public:
Schema _schema;