diff options
Diffstat (limited to 'searchlib')
27 files changed, 297 insertions, 258 deletions
diff --git a/searchlib/src/apps/tests/memoryindexstress_test.cpp b/searchlib/src/apps/tests/memoryindexstress_test.cpp index fec55d35975..60e70566c9e 100644 --- a/searchlib/src/apps/tests/memoryindexstress_test.cpp +++ b/searchlib/src/apps/tests/memoryindexstress_test.cpp @@ -28,7 +28,6 @@ LOG_SETUP("memoryindexstress_test"); using document::AnnotationType; -using document::DataType; using document::Document; using document::DocumentId; using document::DocumentType; @@ -37,11 +36,12 @@ using document::FieldValue; using document::Span; using document::SpanList; using document::StringFieldValue; +using search::ScheduleTaskCallback; +using search::index::schema::DataType; +using search::makeLambdaTask; using search::query::Node; using search::query::SimplePhrase; using search::query::SimpleStringTerm; -using search::makeLambdaTask; -using search::ScheduleTaskCallback; using namespace search::fef; using namespace search::index; using namespace search::memoryindex; @@ -64,8 +64,8 @@ Schema makeSchema() { Schema schema; - schema.addIndexField(Schema::IndexField(title, schema::STRING)); - schema.addIndexField(Schema::IndexField(body, schema::STRING)); + schema.addIndexField(Schema::IndexField(title, DataType::STRING)); + schema.addIndexField(Schema::IndexField(body, DataType::STRING)); return schema; } @@ -78,8 +78,8 @@ makeDocTypeRepoConfig(void) doc_type_name, document::config_builder::Struct(header_name), document::config_builder::Struct(body_name). - addField(title, DataType::T_STRING). - addField(body, DataType::T_STRING)); + addField(title, document::DataType::T_STRING). + addField(body, document::DataType::T_STRING)); return builder.config(); } diff --git a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp index fa54ac8ca66..e7b70dcf237 100644 --- a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp +++ b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp @@ -19,25 +19,26 @@ #include <vespa/log/log.h> LOG_SETUP("vespa-index-inspect"); -using search::index::Schema; -using search::index::SchemaUtil; -using search::index::DictionaryFileRandRead; -using search::index::PostingListFileRandRead; -using search::index::PostingListOffsetAndCounts; -using search::index::PostingListCounts; -using search::index::PostingListHandle; +using search::TuneFileSeqRead; +using search::diskindex::DocIdMapping; +using search::diskindex::FieldReader; +using search::diskindex::PageDict4FileSeqRead; using search::diskindex::PageDict4RandRead; +using search::diskindex::WordNumMapping; using search::diskindex::Zc4PosOccRandRead; +using search::fef::FieldPositionsIterator; using search::fef::TermFieldMatchData; using search::fef::TermFieldMatchDataArray; -using search::fef::FieldPositionsIterator; -using search::queryeval::SearchIterator; +using search::index::DictionaryFileRandRead; using search::index::DocIdAndFeatures; -using search::diskindex::DocIdMapping; -using search::diskindex::WordNumMapping; -using search::diskindex::FieldReader; -using search::diskindex::PageDict4FileSeqRead; -using search::TuneFileSeqRead; +using search::index::PostingListCounts; +using search::index::PostingListFileRandRead; +using search::index::PostingListHandle; +using search::index::PostingListOffsetAndCounts; +using search::index::Schema; +using search::index::SchemaUtil; +using search::index::schema::DataType; +using search::queryeval::SearchIterator; using namespace search::index; namespace @@ -411,7 +412,7 @@ ShowPostingListSubApp::readDocIdLimit(const Schema &schema) uint32_t numIndexFields = schema.getNumIndexFields(); for (uint32_t fieldId = 0; fieldId < numIndexFields; ++fieldId) { const Schema::IndexField &field = schema.getIndexField(fieldId); - if (field.getDataType() == schema::STRING) { + if (field.getDataType() == DataType::STRING) { FieldReader fr; if (!fr.open(_indexDir + "/" + field.getName() + "/", tuneFileRead)) diff --git a/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp b/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp index 33800480492..76f3597bda3 100644 --- a/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp +++ b/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp @@ -9,6 +9,7 @@ LOG_SETUP("bitvector_test"); #include <vespa/vespalib/io/fileutil.h> using namespace search::index; +using search::index::schema::DataType; namespace search { namespace diskindex { @@ -191,7 +192,7 @@ Test::Test() : _schema(), _indexId(0) { - _schema.addIndexField(Schema::IndexField("f1", schema::STRING)); + _schema.addIndexField(Schema::IndexField("f1", DataType::STRING)); } int diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp index d3cebd9944d..5bd731dd9ab 100644 --- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp +++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp @@ -24,30 +24,32 @@ #include <vespa/log/log.h> LOG_SETUP("fieldwriter_test"); - using search::ResultSet; -using search::fef::TermFieldMatchData; -using search::fef::TermFieldMatchDataArray; -using search::queryeval::SearchIterator; +using search::TuneFileRandRead; +using search::TuneFileSeqRead; +using search::TuneFileSeqWrite; +using search::common::FileHeaderContext; +using search::diskindex::CheckPointFile; +using search::diskindex::DocIdMapping; +using search::diskindex::FieldReader; +using search::diskindex::FieldWriter; +using search::diskindex::PageDict4RandRead; +using search::diskindex::WordNumMapping; using search::fakedata::FakeWord; using search::fakedata::FakeWordSet; -using search::index::PostingListParams; +using search::fef::TermFieldMatchData; +using search::fef::TermFieldMatchDataArray; +using search::index::DummyFileHeaderContext; using search::index::PostingListCounts; using search::index::PostingListOffsetAndCounts; +using search::index::PostingListParams; using search::index::Schema; using search::index::SchemaUtil; -using search::common::FileHeaderContext; -using search::index::DummyFileHeaderContext; -using search::diskindex::CheckPointFile; -using search::TuneFileSeqRead; -using search::TuneFileSeqWrite; -using search::TuneFileRandRead; +using search::index::schema::CollectionType; +using search::index::schema::DataType; +using search::queryeval::SearchIterator; using vespalib::nbostream; -using search::diskindex::FieldWriter; -using search::diskindex::FieldReader; -using search::diskindex::DocIdMapping; -using search::diskindex::WordNumMapping; -using search::diskindex::PageDict4RandRead; + using namespace search::index; // needed to resolve external symbol from httpd.h on AIX @@ -188,8 +190,8 @@ WrappedFieldWriter::WrappedFieldWriter(const vespalib::string &namepref, _schema(), _indexId() { - schema::CollectionType ct(schema::SINGLE); - _schema.addIndexField(Schema::IndexField("field1", schema::STRING, ct)); + schema::CollectionType ct(CollectionType::SINGLE); + _schema.addIndexField(Schema::IndexField("field1", DataType::STRING, ct)); _indexId = _schema.getIndexFieldId("field1"); } @@ -324,12 +326,12 @@ WrappedFieldReader::WrappedFieldReader(const vespalib::string &namepref, _oldSchema(), _schema() { - Schema::CollectionType ct(schema::SINGLE); + Schema::CollectionType ct(CollectionType::SINGLE); _oldSchema.addIndexField(Schema::IndexField("field1", - schema::STRING, + DataType::STRING, ct)); _schema.addIndexField(Schema::IndexField("field1", - schema::STRING, + DataType::STRING, ct)); } diff --git a/searchlib/src/tests/diskindex/fusion/fusion_test.cpp b/searchlib/src/tests/diskindex/fusion/fusion_test.cpp index 245da126dbb..90c71361d9a 100644 --- a/searchlib/src/tests/diskindex/fusion/fusion_test.cpp +++ b/searchlib/src/tests/diskindex/fusion/fusion_test.cpp @@ -20,16 +20,18 @@ namespace search { - using document::Document; using fef::FieldPositionsIterator; using fef::TermFieldMatchData; using fef::TermFieldMatchDataArray; -using namespace index; -using search::common::FileHeaderContext; using memoryindex::Dictionary; using memoryindex::DocumentInverter; using queryeval::SearchIterator; +using search::common::FileHeaderContext; +using search::index::schema::CollectionType; +using search::index::schema::DataType; + +using namespace index; namespace diskindex { @@ -247,19 +249,20 @@ Test::requireThatFusionIsWorking(const vespalib::string &prefix, schema.addIndexField(Schema::IndexField(iField.getName(), iField.getDataType(), iField.getCollectionType())); - if (iField.getCollectionType() == schema::WEIGHTEDSET) + if (iField.getCollectionType() == CollectionType::WEIGHTEDSET) { schema2.addIndexField(Schema::IndexField(iField.getName(), - iField.getDataType(), - schema::ARRAY)); - else + iField.getDataType(), + CollectionType::ARRAY)); + } else { schema2.addIndexField(Schema::IndexField(iField.getName(), - iField.getDataType(), - iField.getCollectionType())); + iField.getDataType(), + iField.getCollectionType())); + } schema3.addIndexField(Schema::IndexField(iField.getName(), iField.getDataType(), - schema::SINGLE)); + CollectionType::SINGLE)); } - schema3.addIndexField(Schema::IndexField("f4", schema::STRING)); + schema3.addIndexField(Schema::IndexField("f4", DataType::STRING)); schema.addFieldSet(Schema::FieldSet("nc0"). addField("f0").addField("f1")); schema2.addFieldSet(Schema::FieldSet("nc0"). @@ -447,10 +450,10 @@ Test::requireThatFusionIsWorking(const vespalib::string &prefix, Test::Test() : _schema() { - _schema.addIndexField(Schema::IndexField("f0", schema::STRING)); - _schema.addIndexField(Schema::IndexField("f1", schema::STRING)); - _schema.addIndexField(Schema::IndexField("f2", schema::STRING, schema::ARRAY)); - _schema.addIndexField(Schema::IndexField("f3", schema::STRING, schema::WEIGHTEDSET)); + _schema.addIndexField(Schema::IndexField("f0", DataType::STRING)); + _schema.addIndexField(Schema::IndexField("f1", DataType::STRING)); + _schema.addIndexField(Schema::IndexField("f2", DataType::STRING, CollectionType::ARRAY)); + _schema.addIndexField(Schema::IndexField("f3", DataType::STRING, CollectionType::WEIGHTEDSET)); } int diff --git a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp index 37fc78df460..17999dbdb37 100644 --- a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp +++ b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp @@ -16,30 +16,33 @@ #include <vespa/log/log.h> LOG_SETUP("pagedict4test"); -using search::bitcompression::PostingListCountFileEncodeContext; -using search::bitcompression::PostingListCountFileDecodeContext; -using search::index::PostingListCounts; -using search::index::PostingListOffsetAndCounts; -using search::index::PostingListParams; -using search::bitcompression::PageDict4SSWriter; -using search::bitcompression::PageDict4SPWriter; +using search::bitcompression::PageDict4PLookupRes; using search::bitcompression::PageDict4PWriter; using search::bitcompression::PageDict4Reader; -using search::bitcompression::PageDict4SSReader; -using search::bitcompression::PageDict4SSLookupRes; using search::bitcompression::PageDict4SPLookupRes; -using search::bitcompression::PageDict4PLookupRes; -using search::index::Schema; -using search::index::DictionaryFileSeqRead; -using search::index::DictionaryFileSeqWrite; -using search::index::DictionaryFileRandRead; +using search::bitcompression::PageDict4SPWriter; +using search::bitcompression::PageDict4SSLookupRes; +using search::bitcompression::PageDict4SSReader; +using search::bitcompression::PageDict4SSWriter; +using search::bitcompression::PostingListCountFileDecodeContext; +using search::bitcompression::PostingListCountFileEncodeContext; using search::diskindex::PageDict4FileSeqRead; using search::diskindex::PageDict4FileSeqWrite; using search::diskindex::PageDict4RandRead; +using search::index::DictionaryFileRandRead; +using search::index::DictionaryFileSeqRead; +using search::index::DictionaryFileSeqWrite; using search::index::DummyFileHeaderContext; +using search::index::PostingListCounts; +using search::index::PostingListOffsetAndCounts; +using search::index::PostingListParams; +using search::index::Schema; +using search::index::schema::CollectionType; +using search::index::schema::DataType; + using namespace search::index; -typedef search::bitcompression::PageDict4StartOffset StartOffset; +using StartOffset = search::bitcompression::PageDict4StartOffset; namespace { @@ -645,8 +648,8 @@ testWords(const std::string &logname, fn << "f0"; schema.addIndexField(Schema:: IndexField(fn.str(), - schema::STRING, - schema::SINGLE)); + DataType::STRING, + CollectionType::SINGLE)); indexes.push_back(0); } { diff --git a/searchlib/src/tests/features/imported_dot_product/imported_dot_product_test.cpp b/searchlib/src/tests/features/imported_dot_product/imported_dot_product_test.cpp index a01b1ad1575..59dacf3c69a 100644 --- a/searchlib/src/tests/features/imported_dot_product/imported_dot_product_test.cpp +++ b/searchlib/src/tests/features/imported_dot_product/imported_dot_product_test.cpp @@ -11,6 +11,7 @@ using namespace search::attribute; using namespace search::features; using namespace search::fef; using namespace search::fef::test; +using namespace search::index; template <typename T> std::unique_ptr<fef::Anything> create_param(const vespalib::string& param) { @@ -45,9 +46,9 @@ struct FixtureBase : ImportedAttributeFixture { feature.getQueryEnv().getObjectStore().add("dotProduct.vector.object", std::move(pre_parsed)); } feature.getIndexEnv().getAttributeMap().add(imported_attr); - fef::CollectionType collection_type( + schema::CollectionType collection_type( (imported_attr->getCollectionType() == attribute::CollectionType::ARRAY) - ? fef::CollectionType::ARRAY : fef::CollectionType::WEIGHTEDSET); + ? schema::CollectionType::ARRAY : schema::CollectionType::WEIGHTEDSET); feature.getIndexEnv().getBuilder().addField( FieldType::ATTRIBUTE, collection_type, imported_attr->getName()); ASSERT_TRUE(feature.setup()); @@ -109,7 +110,7 @@ struct ArrayFixture : FixtureBase { feature.getIndexEnv().getAttributeMap().add(imported_attr); feature.getIndexEnv().getBuilder().addField( - FieldType::ATTRIBUTE, fef::CollectionType::ARRAY, imported_attr->getName()); + FieldType::ATTRIBUTE, schema::CollectionType::ARRAY, imported_attr->getName()); bp.setup(feature.getIndexEnv(), params); feature.getQueryEnv().getProperties().add("dotProduct.fancyvector", input_vector); diff --git a/searchlib/src/tests/index/docbuilder/docbuilder_test.cpp b/searchlib/src/tests/index/docbuilder/docbuilder_test.cpp index 446e782f092..dee07c3d366 100644 --- a/searchlib/src/tests/index/docbuilder/docbuilder_test.cpp +++ b/searchlib/src/tests/index/docbuilder/docbuilder_test.cpp @@ -21,6 +21,7 @@ LOG_SETUP("docbuilder_test"); #include <iostream> using namespace document; +using search::index::schema::CollectionType; namespace search { namespace index { @@ -46,38 +47,38 @@ void Test::testBuilder() { Schema s; - s.addIndexField(Schema::IndexField("ia", schema::STRING)); - s.addIndexField(Schema::IndexField("ib", schema::STRING, schema::ARRAY)); - s.addIndexField(Schema::IndexField("ic", schema::STRING, schema::WEIGHTEDSET)); - s.addUriIndexFields(Schema::IndexField("iu", schema::STRING)); - s.addUriIndexFields(Schema::IndexField("iau", schema::STRING, schema::ARRAY)); - s.addUriIndexFields(Schema::IndexField("iwu", schema::STRING, schema::WEIGHTEDSET)); - s.addAttributeField(Schema::AttributeField("aa", schema::INT32)); - s.addAttributeField(Schema::AttributeField("ab", schema::FLOAT)); - s.addAttributeField(Schema::AttributeField("ac", schema::STRING)); - s.addAttributeField(Schema::AttributeField("ad", schema::INT32, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("ae", schema::FLOAT, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("af", schema::STRING, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("ag", schema::INT32, schema::WEIGHTEDSET)); - s.addAttributeField(Schema::AttributeField("ah", schema::FLOAT, schema::WEIGHTEDSET)); - s.addAttributeField(Schema::AttributeField("ai", schema::STRING, schema::WEIGHTEDSET)); - s.addAttributeField(Schema::AttributeField("asp1", schema::INT32)); - s.addAttributeField(Schema::AttributeField("asp2", schema::INT64)); - s.addAttributeField(Schema::AttributeField("aap1", schema::INT32, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("aap2", schema::INT64, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("awp1", schema::INT32, schema::WEIGHTEDSET)); - s.addAttributeField(Schema::AttributeField("awp2", schema::INT64, schema::WEIGHTEDSET)); + s.addIndexField(Schema::IndexField("ia", schema::DataType::STRING)); + s.addIndexField(Schema::IndexField("ib", schema::DataType::STRING, CollectionType::ARRAY)); + s.addIndexField(Schema::IndexField("ic", schema::DataType::STRING, CollectionType::WEIGHTEDSET)); + s.addUriIndexFields(Schema::IndexField("iu", schema::DataType::STRING)); + s.addUriIndexFields(Schema::IndexField("iau", schema::DataType::STRING, CollectionType::ARRAY)); + s.addUriIndexFields(Schema::IndexField("iwu", schema::DataType::STRING, CollectionType::WEIGHTEDSET)); + s.addAttributeField(Schema::AttributeField("aa", schema::DataType::INT32)); + s.addAttributeField(Schema::AttributeField("ab", schema::DataType::FLOAT)); + s.addAttributeField(Schema::AttributeField("ac", schema::DataType::STRING)); + s.addAttributeField(Schema::AttributeField("ad", schema::DataType::INT32, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("ae", schema::DataType::FLOAT, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("af", schema::DataType::STRING, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("ag", schema::DataType::INT32, CollectionType::WEIGHTEDSET)); + s.addAttributeField(Schema::AttributeField("ah", schema::DataType::FLOAT, CollectionType::WEIGHTEDSET)); + s.addAttributeField(Schema::AttributeField("ai", schema::DataType::STRING, CollectionType::WEIGHTEDSET)); + s.addAttributeField(Schema::AttributeField("asp1", schema::DataType::INT32)); + s.addAttributeField(Schema::AttributeField("asp2", schema::DataType::INT64)); + s.addAttributeField(Schema::AttributeField("aap1", schema::DataType::INT32, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("aap2", schema::DataType::INT64, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("awp1", schema::DataType::INT32, CollectionType::WEIGHTEDSET)); + s.addAttributeField(Schema::AttributeField("awp2", schema::DataType::INT64, CollectionType::WEIGHTEDSET)); - s.addSummaryField(Schema::SummaryField("sa", schema::INT8)); - s.addSummaryField(Schema::SummaryField("sb", schema::INT16)); - s.addSummaryField(Schema::SummaryField("sc", schema::INT32)); - s.addSummaryField(Schema::SummaryField("sd", schema::INT64)); - s.addSummaryField(Schema::SummaryField("se", schema::FLOAT)); - s.addSummaryField(Schema::SummaryField("sf", schema::DOUBLE)); - s.addSummaryField(Schema::SummaryField("sg", schema::STRING)); - s.addSummaryField(Schema::SummaryField("sh", schema::RAW)); - s.addSummaryField(Schema::SummaryField("si", schema::RAW, schema::ARRAY)); - s.addSummaryField(Schema::SummaryField("sj", schema::RAW, schema::WEIGHTEDSET)); + s.addSummaryField(Schema::SummaryField("sa", schema::DataType::INT8)); + s.addSummaryField(Schema::SummaryField("sb", schema::DataType::INT16)); + s.addSummaryField(Schema::SummaryField("sc", schema::DataType::INT32)); + s.addSummaryField(Schema::SummaryField("sd", schema::DataType::INT64)); + s.addSummaryField(Schema::SummaryField("se", schema::DataType::FLOAT)); + s.addSummaryField(Schema::SummaryField("sf", schema::DataType::DOUBLE)); + s.addSummaryField(Schema::SummaryField("sg", schema::DataType::STRING)); + s.addSummaryField(Schema::SummaryField("sh", schema::DataType::RAW)); + s.addSummaryField(Schema::SummaryField("si", schema::DataType::RAW, CollectionType::ARRAY)); + s.addSummaryField(Schema::SummaryField("sj", schema::DataType::RAW, CollectionType::WEIGHTEDSET)); DocBuilder b(s); Document::UP doc; diff --git a/searchlib/src/tests/index/doctypebuilder/doctypebuilder_test.cpp b/searchlib/src/tests/index/doctypebuilder/doctypebuilder_test.cpp index 9f04563ad8b..8dd4afbc8d7 100644 --- a/searchlib/src/tests/index/doctypebuilder/doctypebuilder_test.cpp +++ b/searchlib/src/tests/index/doctypebuilder/doctypebuilder_test.cpp @@ -9,19 +9,22 @@ using namespace document; namespace search { namespace index { +using schema::CollectionType; +using schema::DataType; + TEST("testSearchDocType") { Schema s; - s.addIndexField(Schema::IndexField("ia", schema::STRING)); - s.addIndexField(Schema::IndexField("ib", schema::STRING, schema::ARRAY)); - s.addIndexField(Schema::IndexField("ic", schema::STRING, schema::WEIGHTEDSET)); - s.addUriIndexFields(Schema::IndexField("iu", schema::STRING)); - s.addUriIndexFields(Schema::IndexField("iau", schema::STRING, schema::ARRAY)); - s.addUriIndexFields(Schema::IndexField("iwu", schema::STRING, schema::WEIGHTEDSET)); - s.addAttributeField(Schema::AttributeField("aa", schema::INT32)); - s.addAttributeField(Schema::AttributeField("spos", schema::INT64)); - s.addAttributeField(Schema::AttributeField("apos", schema::INT64, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("wpos", schema::INT64, schema::WEIGHTEDSET)); - s.addSummaryField(Schema::SummaryField("sa", schema::STRING)); + s.addIndexField(Schema::IndexField("ia", DataType::STRING)); + s.addIndexField(Schema::IndexField("ib", DataType::STRING, CollectionType::ARRAY)); + s.addIndexField(Schema::IndexField("ic", DataType::STRING, CollectionType::WEIGHTEDSET)); + s.addUriIndexFields(Schema::IndexField("iu", DataType::STRING)); + s.addUriIndexFields(Schema::IndexField("iau", DataType::STRING, CollectionType::ARRAY)); + s.addUriIndexFields(Schema::IndexField("iwu", DataType::STRING, CollectionType::WEIGHTEDSET)); + s.addAttributeField(Schema::AttributeField("aa", DataType::INT32)); + s.addAttributeField(Schema::AttributeField("spos", DataType::INT64)); + s.addAttributeField(Schema::AttributeField("apos", DataType::INT64, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("wpos", DataType::INT64, CollectionType::WEIGHTEDSET)); + s.addSummaryField(Schema::SummaryField("sa", DataType::STRING)); DocTypeBuilder docTypeBuilder(s); document::DocumenttypesConfig config = docTypeBuilder.makeConfig(); @@ -52,8 +55,8 @@ TEST("testSearchDocType") { TEST("require that multiple fields can have the same type") { Schema s; - s.addIndexField(Schema::IndexField("array1", schema::STRING, schema::ARRAY)); - s.addIndexField(Schema::IndexField("array2", schema::STRING, schema::ARRAY)); + s.addIndexField(Schema::IndexField("array1", DataType::STRING, CollectionType::ARRAY)); + s.addIndexField(Schema::IndexField("array2", DataType::STRING, CollectionType::ARRAY)); DocTypeBuilder docTypeBuilder(s); document::DocumenttypesConfig config = docTypeBuilder.makeConfig(); DocumentTypeRepo repo(config); diff --git a/searchlib/src/tests/memoryindex/datastore/featurestore_test.cpp b/searchlib/src/tests/memoryindex/datastore/featurestore_test.cpp index c13aeaa1053..b7207966ece 100644 --- a/searchlib/src/tests/memoryindex/datastore/featurestore_test.cpp +++ b/searchlib/src/tests/memoryindex/datastore/featurestore_test.cpp @@ -9,6 +9,9 @@ using namespace search::btree; using namespace search::datastore; using namespace search::index; +using search::index::schema::CollectionType; +using search::index::schema::DataType; + namespace search { @@ -217,8 +220,8 @@ Test::requireThatAddFeaturesTriggersChangeOfBuffer(void) Test::Test() : _schema() { - _schema.addIndexField(Schema::IndexField("f0", schema::STRING)); - _schema.addIndexField(Schema::IndexField("f1", schema::STRING, schema::WEIGHTEDSET)); + _schema.addIndexField(Schema::IndexField("f0", DataType::STRING)); + _schema.addIndexField(Schema::IndexField("f1", DataType::STRING, CollectionType::WEIGHTEDSET)); } diff --git a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp index 4ef2e4e3617..47a49d25f5f 100644 --- a/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp +++ b/searchlib/src/tests/memoryindex/dictionary/dictionary_test.cpp @@ -27,10 +27,13 @@ using namespace btree; using namespace datastore; using namespace fef; using namespace index; -using queryeval::SearchIterator; + using document::Document; -using vespalib::GenerationHandler; +using queryeval::SearchIterator; +using search::index::schema::CollectionType; +using search::index::schema::DataType; using test::SearchIteratorVerifier; +using vespalib::GenerationHandler; namespace memoryindex { @@ -577,10 +580,10 @@ struct Fixture { Schema _schema; Fixture() : _schema() { - _schema.addIndexField(Schema::IndexField("f0", schema::STRING)); - _schema.addIndexField(Schema::IndexField("f1", schema::STRING)); - _schema.addIndexField(Schema::IndexField("f2", schema::STRING, schema::ARRAY)); - _schema.addIndexField(Schema::IndexField("f3", schema::STRING, schema::WEIGHTEDSET)); + _schema.addIndexField(Schema::IndexField("f0", DataType::STRING)); + _schema.addIndexField(Schema::IndexField("f1", DataType::STRING)); + _schema.addIndexField(Schema::IndexField("f2", DataType::STRING, CollectionType::ARRAY)); + _schema.addIndexField(Schema::IndexField("f3", DataType::STRING, CollectionType::WEIGHTEDSET)); } const Schema & getSchema() const { return _schema; } }; @@ -1160,9 +1163,9 @@ public: UriFixture() : _schema() { - _schema.addUriIndexFields(Schema::IndexField("iu", schema::STRING)); - _schema.addUriIndexFields(Schema::IndexField("iau", schema::STRING, schema::ARRAY)); - _schema.addUriIndexFields(Schema::IndexField("iwu", schema::STRING, schema::WEIGHTEDSET)); + _schema.addUriIndexFields(Schema::IndexField("iu", DataType::STRING)); + _schema.addUriIndexFields(Schema::IndexField("iau", DataType::STRING, CollectionType::ARRAY)); + _schema.addUriIndexFields(Schema::IndexField("iwu", DataType::STRING, CollectionType::WEIGHTEDSET)); } const Schema & getSchema() const { return _schema; } }; @@ -1368,7 +1371,7 @@ public: SingleFieldFixture() : _schema() { - _schema.addIndexField(Schema::IndexField("i", schema::STRING)); + _schema.addIndexField(Schema::IndexField("i", DataType::STRING)); } const Schema & getSchema() const { return _schema; } }; diff --git a/searchlib/src/tests/memoryindex/documentinverter/documentinverter_test.cpp b/searchlib/src/tests/memoryindex/documentinverter/documentinverter_test.cpp index d69780b9516..89098848cc5 100644 --- a/searchlib/src/tests/memoryindex/documentinverter/documentinverter_test.cpp +++ b/searchlib/src/tests/memoryindex/documentinverter/documentinverter_test.cpp @@ -13,10 +13,12 @@ namespace search { - using document::Document; using index::DocBuilder; using index::Schema; +using index::schema::CollectionType; +using index::schema::DataType; + using namespace index; namespace memoryindex { @@ -103,10 +105,10 @@ struct Fixture makeSchema() { Schema schema; - schema.addIndexField(Schema::IndexField("f0", schema::STRING)); - schema.addIndexField(Schema::IndexField("f1", schema::STRING)); - schema.addIndexField(Schema::IndexField("f2", schema::STRING, schema::ARRAY)); - schema.addIndexField(Schema::IndexField("f3", schema::STRING, schema::WEIGHTEDSET)); + schema.addIndexField(Schema::IndexField("f0", DataType::STRING)); + schema.addIndexField(Schema::IndexField("f1", DataType::STRING)); + schema.addIndexField(Schema::IndexField("f2", DataType::STRING, CollectionType::ARRAY)); + schema.addIndexField(Schema::IndexField("f3", DataType::STRING, CollectionType::WEIGHTEDSET)); return schema; } diff --git a/searchlib/src/tests/memoryindex/fieldinverter/fieldinverter_test.cpp b/searchlib/src/tests/memoryindex/fieldinverter/fieldinverter_test.cpp index eb86015bb27..df292ec2b1d 100644 --- a/searchlib/src/tests/memoryindex/fieldinverter/fieldinverter_test.cpp +++ b/searchlib/src/tests/memoryindex/fieldinverter/fieldinverter_test.cpp @@ -10,10 +10,12 @@ namespace search { - using document::Document; using index::DocBuilder; using index::Schema; +using index::schema::CollectionType; +using index::schema::DataType; + using namespace index; namespace memoryindex { @@ -111,10 +113,10 @@ struct Fixture makeSchema() { Schema schema; - schema.addIndexField(Schema::IndexField("f0", schema::STRING)); - schema.addIndexField(Schema::IndexField("f1", schema::STRING)); - schema.addIndexField(Schema::IndexField("f2", schema::STRING, schema::ARRAY)); - schema.addIndexField(Schema::IndexField("f3", schema::STRING, schema::WEIGHTEDSET)); + schema.addIndexField(Schema::IndexField("f0", DataType::STRING)); + schema.addIndexField(Schema::IndexField("f1", DataType::STRING)); + schema.addIndexField(Schema::IndexField("f2", DataType::STRING, CollectionType::ARRAY)); + schema.addIndexField(Schema::IndexField("f3", DataType::STRING, CollectionType::WEIGHTEDSET)); return schema; } diff --git a/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp b/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp index a1302d7de78..9ed5ff16c9e 100644 --- a/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp +++ b/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp @@ -22,11 +22,12 @@ LOG_SETUP("memoryindex_test"); using document::Document; using document::FieldValue; +using search::ScheduleTaskCallback; +using search::index::schema::DataType; +using search::makeLambdaTask; using search::query::Node; using search::query::SimplePhrase; using search::query::SimpleStringTerm; -using search::makeLambdaTask; -using search::ScheduleTaskCallback; using namespace search::fef; using namespace search::index; using namespace search::memoryindex; @@ -37,7 +38,7 @@ using namespace search::queryeval; struct Setup { Schema schema; Setup &field(const std::string &name) { - schema.addIndexField(Schema::IndexField(name, schema::STRING)); + schema.addIndexField(Schema::IndexField(name, DataType::STRING)); return *this; } }; diff --git a/searchlib/src/tests/memoryindex/urlfieldinverter/urlfieldinverter_test.cpp b/searchlib/src/tests/memoryindex/urlfieldinverter/urlfieldinverter_test.cpp index 9e6f401cd4c..c50ebc056c8 100644 --- a/searchlib/src/tests/memoryindex/urlfieldinverter/urlfieldinverter_test.cpp +++ b/searchlib/src/tests/memoryindex/urlfieldinverter/urlfieldinverter_test.cpp @@ -14,6 +14,9 @@ namespace search { using document::Document; +using index::schema::CollectionType; +using index::schema::DataType; + using namespace index; @@ -189,7 +192,7 @@ struct Fixture makeSchema(Schema::CollectionType collectionType) { Schema schema; - schema.addUriIndexFields(Schema::IndexField("url", index::schema::STRING, collectionType)); + schema.addUriIndexFields(Schema::IndexField("url", DataType::STRING, collectionType)); return schema; } @@ -246,7 +249,7 @@ struct Fixture }; -TEST_F("requireThatSingleUrlFieldWorks", Fixture(schema::SINGLE)) +TEST_F("requireThatSingleUrlFieldWorks", Fixture(CollectionType::SINGLE)) { f.invertDocument(10, *makeDoc10Single(f._b)); f.pushDocuments(); @@ -285,7 +288,7 @@ TEST_F("requireThatSingleUrlFieldWorks", Fixture(schema::SINGLE)) } -TEST_F("requireThatArrayUrlFieldWorks", Fixture(schema::ARRAY)) +TEST_F("requireThatArrayUrlFieldWorks", Fixture(CollectionType::ARRAY)) { f.invertDocument(10, *makeDoc10Array(f._b)); f.pushDocuments(); @@ -328,7 +331,7 @@ TEST_F("requireThatArrayUrlFieldWorks", Fixture(schema::ARRAY)) f._inserter.toStr()); } -TEST_F("requireThatWeightedSetFieldWorks", Fixture(schema::WEIGHTEDSET)) +TEST_F("requireThatWeightedSetFieldWorks", Fixture(CollectionType::WEIGHTEDSET)) { f.invertDocument(10, *makeDoc10WeightedSet(f._b)); f.pushDocuments(); @@ -373,7 +376,7 @@ TEST_F("requireThatWeightedSetFieldWorks", Fixture(schema::WEIGHTEDSET)) f._inserter.toStr()); } -TEST_F("requireThatAnnotatedSingleUrlFieldWorks", Fixture(schema::SINGLE)) +TEST_F("requireThatAnnotatedSingleUrlFieldWorks", Fixture(CollectionType::SINGLE)) { f.enableAnnotations(); f.invertDocument(10, *makeDoc10Single(f._b)); @@ -414,7 +417,7 @@ TEST_F("requireThatAnnotatedSingleUrlFieldWorks", Fixture(schema::SINGLE)) } -TEST_F("requireThatAnnotatedArrayUrlFieldWorks", Fixture(schema::ARRAY)) +TEST_F("requireThatAnnotatedArrayUrlFieldWorks", Fixture(CollectionType::ARRAY)) { f.enableAnnotations(); f.invertDocument(10, *makeDoc10Array(f._b)); @@ -460,7 +463,7 @@ TEST_F("requireThatAnnotatedArrayUrlFieldWorks", Fixture(schema::ARRAY)) } TEST_F("requireThatAnnotatedWeightedSetFieldWorks", - Fixture(schema::WEIGHTEDSET)) + Fixture(CollectionType::WEIGHTEDSET)) { f.enableAnnotations(); f._inserter.setVerbose(); @@ -509,14 +512,14 @@ TEST_F("requireThatAnnotatedWeightedSetFieldWorks", } -TEST_F("requireThatEmptySingleFieldWorks", Fixture(schema::SINGLE)) +TEST_F("requireThatEmptySingleFieldWorks", Fixture(CollectionType::SINGLE)) { f.invertDocument(10, *makeDoc10Empty(f._b)); f.pushDocuments(); EXPECT_EQUAL("", f._inserter.toStr()); } -TEST_F("requireThatEmptyArrayFieldWorks", Fixture(schema::ARRAY)) +TEST_F("requireThatEmptyArrayFieldWorks", Fixture(CollectionType::ARRAY)) { f.invertDocument(10, *makeDoc10Empty(f._b)); f.pushDocuments(); @@ -524,14 +527,14 @@ TEST_F("requireThatEmptyArrayFieldWorks", Fixture(schema::ARRAY)) f._inserter.toStr()); } -TEST_F("requireThatEmptyWeightedSetFieldWorks", Fixture(schema::WEIGHTEDSET)) +TEST_F("requireThatEmptyWeightedSetFieldWorks", Fixture(CollectionType::WEIGHTEDSET)) { f.invertDocument(10, *makeDoc10Empty(f._b)); f.pushDocuments(); EXPECT_EQUAL("", f._inserter.toStr()); } -TEST_F("requireThatAnnotatedEmptySingleFieldWorks", Fixture(schema::SINGLE)) +TEST_F("requireThatAnnotatedEmptySingleFieldWorks", Fixture(CollectionType::SINGLE)) { f.enableAnnotations(); f.invertDocument(10, *makeDoc10Empty(f._b)); @@ -539,7 +542,7 @@ TEST_F("requireThatAnnotatedEmptySingleFieldWorks", Fixture(schema::SINGLE)) EXPECT_EQUAL("", f._inserter.toStr()); } -TEST_F("requireThatAnnotatedEmptyArrayFieldWorks", Fixture(schema::ARRAY)) +TEST_F("requireThatAnnotatedEmptyArrayFieldWorks", Fixture(CollectionType::ARRAY)) { f.enableAnnotations(); f.invertDocument(10, *makeDoc10Empty(f._b)); @@ -547,7 +550,7 @@ TEST_F("requireThatAnnotatedEmptyArrayFieldWorks", Fixture(schema::ARRAY)) EXPECT_EQUAL("", f._inserter.toStr()); } -TEST_F("requireThatAnnotatedEmptyWeightedSetFieldWorks", Fixture(schema::WEIGHTEDSET)) +TEST_F("requireThatAnnotatedEmptyWeightedSetFieldWorks", Fixture(CollectionType::WEIGHTEDSET)) { f.enableAnnotations(); f.invertDocument(10, *makeDoc10Empty(f._b)); diff --git a/searchlib/src/tests/postinglistbm/postinglistbm.cpp b/searchlib/src/tests/postinglistbm/postinglistbm.cpp index 14ff86d4db0..346243099cd 100644 --- a/searchlib/src/tests/postinglistbm/postinglistbm.cpp +++ b/searchlib/src/tests/postinglistbm/postinglistbm.cpp @@ -16,7 +16,10 @@ using search::ResultSet; using search::fef::TermFieldMatchData; using search::fef::TermFieldMatchDataArray; +using search::index::schema::CollectionType; +using search::index::schema::DataType; using search::queryeval::SearchIterator; + using namespace search::index; using namespace search::fakedata; @@ -372,8 +375,8 @@ PostingListBM::Main(void) do { Schema schema; Schema::IndexField indexField("field0", - schema::STRING, - schema::SINGLE); + DataType::STRING, + CollectionType::SINGLE); schema.addIndexField(indexField); std::unique_ptr<FPFactory> ff(getFPFactory(optArg, schema)); if (ff.get() == NULL) { diff --git a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp index 68b7b7513b0..d209c99946b 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp +++ b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp @@ -131,17 +131,17 @@ PosOccFieldParams::setSchemaParams(const Schema &schema, uint32_t fieldId) assert(fieldId < schema.getNumIndexFields()); const Schema::IndexField &field = schema.getIndexField(fieldId); switch (field.getCollectionType()) { - case schema::SINGLE: + case schema::CollectionType::SINGLE: _collectionType = SINGLE; _hasElements = false; _hasElementWeights = false; break; - case schema::ARRAY: + case schema::CollectionType::ARRAY: _collectionType = ARRAY; _hasElements = true; _hasElementWeights = false; break; - case schema::WEIGHTEDSET: + case schema::CollectionType::WEIGHTEDSET: _collectionType = WEIGHTEDSET; _hasElements = true; _hasElementWeights = true; @@ -165,17 +165,17 @@ PosOccFieldParams::readHeader(const vespalib::GenericHeader &header, _name = header.getTag(nameKey).asString(); Schema::CollectionType ct = schema::collectionTypeFromName(header.getTag(collKey).asString()); switch (ct) { - case schema::SINGLE: + case schema::CollectionType::SINGLE: _collectionType = SINGLE; _hasElements = false; _hasElementWeights = false; break; - case schema::ARRAY: + case schema::CollectionType::ARRAY: _collectionType = ARRAY; _hasElements = true; _hasElementWeights = false; break; - case schema::WEIGHTEDSET: + case schema::CollectionType::WEIGHTEDSET: _collectionType = WEIGHTEDSET; _hasElements = true; _hasElementWeights = true; @@ -196,16 +196,16 @@ PosOccFieldParams::writeHeader(vespalib::GenericHeader &header, vespalib::string collKey(prefix + "collectionType"); vespalib::string avgElemLenKey(prefix + "avgElemLen"); header.putTag(GenericHeader::Tag(nameKey, _name)); - Schema::CollectionType ct(schema::SINGLE); + Schema::CollectionType ct(schema::CollectionType::SINGLE); switch (_collectionType) { case SINGLE: - ct = schema::SINGLE; + ct = schema::CollectionType::SINGLE; break; case ARRAY: - ct = schema::ARRAY; + ct = schema::CollectionType::ARRAY; break; case WEIGHTEDSET: - ct = schema::WEIGHTEDSET; + ct = schema::CollectionType::WEIGHTEDSET; break; default: LOG(error, diff --git a/searchlib/src/vespa/searchlib/diskindex/fusion.cpp b/searchlib/src/vespa/searchlib/diskindex/fusion.cpp index 2421e46f528..8cae80fb892 100644 --- a/searchlib/src/vespa/searchlib/diskindex/fusion.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/fusion.cpp @@ -20,14 +20,15 @@ LOG_SETUP(".diskindex.fusion"); using search::FileKit; -using search::index::PostingListParams; -using search::index::Schema; -using search::index::SchemaUtil; +using search::PostingPriorityQueue; using search::common::FileHeaderContext; using search::diskindex::DocIdMapping; using search::diskindex::WordNumMapping; -using search::PostingPriorityQueue; using search::docsummary::DocumentSummary; +using search::index::PostingListParams; +using search::index::Schema; +using search::index::SchemaUtil; +using search::index::schema::DataType; using vespalib::getLastErrorString; @@ -400,7 +401,7 @@ Fusion::ReadMappingFiles(const SchemaUtil::IndexIterator *index) std::vector<uint32_t> oldIndexes; const Schema &oldSchema = oi.getSchema(); if (!SchemaUtil::getIndexIds(oldSchema, - index::schema::STRING, + DataType::STRING, oldIndexes)) return false; if (oldIndexes.empty()) { diff --git a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp index 888bfcff1e4..20d8a045efb 100644 --- a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp @@ -19,12 +19,13 @@ namespace diskindex { namespace { +using common::FileHeaderContext; using index::DocIdAndFeatures; using index::PostingListCounts; using index::Schema; using index::SchemaUtil; using index::WordDocElementFeatures; -using common::FileHeaderContext; +using index::schema::DataType; using vespalib::getLastErrorString; static uint32_t @@ -543,7 +544,7 @@ IndexBuilder::IndexBuilder(const Schema &schema) const Schema::IndexField &iField = schema.getIndexField(i); FieldHandle fh(schema, i, this); // Only know how to handle string index for now. - if (iField.getDataType() == index::schema::STRING) + if (iField.getDataType() == DataType::STRING) fh.setValid(); _fields.push_back(fh); } diff --git a/searchlib/src/vespa/searchlib/index/docbuilder.cpp b/searchlib/src/vespa/searchlib/index/docbuilder.cpp index 805dbba6c02..d06b867c00d 100644 --- a/searchlib/src/vespa/searchlib/index/docbuilder.cpp +++ b/searchlib/src/vespa/searchlib/index/docbuilder.cpp @@ -15,6 +15,8 @@ using namespace document; using namespace search::index; + +using search::index::schema::CollectionType; using vespalib::Utf8Reader; using vespalib::Utf8Writer; using vespalib::geo::ZCurve; @@ -24,8 +26,8 @@ namespace { void insertStr(const Schema::Field & sfield, document::FieldValue * fvalue, const vespalib::string & val) { - if (sfield.getDataType() == schema::STRING || - sfield.getDataType() == schema::RAW) + if (sfield.getDataType() == schema::DataType::STRING || + sfield.getDataType() == schema::DataType::RAW) { (dynamic_cast<LiteralFieldValueB *>(fvalue))->setValue(val); } else { @@ -36,13 +38,13 @@ insertStr(const Schema::Field & sfield, document::FieldValue * fvalue, const ves void insertInt(const Schema::Field & sfield, document::FieldValue * fvalue, int64_t val) { - if (sfield.getDataType() == schema::INT8) { + if (sfield.getDataType() == schema::DataType::INT8) { (dynamic_cast<ByteFieldValue *>(fvalue))->setValue((uint8_t)val); - } else if (sfield.getDataType() == schema::INT16) { + } else if (sfield.getDataType() == schema::DataType::INT16) { (dynamic_cast<ShortFieldValue *>(fvalue))->setValue((int16_t)val); - } else if (sfield.getDataType() == schema::INT32) { + } else if (sfield.getDataType() == schema::DataType::INT32) { (dynamic_cast<IntFieldValue *>(fvalue))->setValue((int32_t)val); - } else if (sfield.getDataType() == schema::INT64) { + } else if (sfield.getDataType() == schema::DataType::INT64) { (dynamic_cast<LongFieldValue *>(fvalue))->setValue(val); } else { throw DocBuilder::Error(vespalib::make_string("Field '%s' not compatible", sfield.getName().c_str())); @@ -52,9 +54,9 @@ insertInt(const Schema::Field & sfield, document::FieldValue * fvalue, int64_t v void insertFloat(const Schema::Field & sfield, document::FieldValue * fvalue, double val) { - if (sfield.getDataType() == schema::FLOAT) { + if (sfield.getDataType() == schema::DataType::FLOAT) { (dynamic_cast<FloatFieldValue *>(fvalue))->setValue((float)val); - } else if (sfield.getDataType() == schema::DOUBLE) { + } else if (sfield.getDataType() == schema::DataType::DOUBLE) { (dynamic_cast<DoubleFieldValue *>(fvalue))->setValue(val); } else { throw DocBuilder::Error(vespalib::make_string("Field '%s' not compatible", sfield.getName().c_str())); @@ -64,7 +66,7 @@ insertFloat(const Schema::Field & sfield, document::FieldValue * fvalue, double void insertPredicate(const Schema::Field &sfield, document::FieldValue *fvalue, std::unique_ptr<vespalib::Slime> val) { - if (sfield.getDataType() == schema::BOOLEANTREE) { + if (sfield.getDataType() == schema::DataType::BOOLEANTREE) { *(dynamic_cast<PredicateFieldValue *>(fvalue)) = PredicateFieldValue(std::move(val)); } else { @@ -77,7 +79,7 @@ void insertPredicate(const Schema::Field &sfield, void insertTensor(const Schema::Field &schemaField, document::FieldValue *fvalue, std::unique_ptr<vespalib::tensor::Tensor> val) { - if (schemaField.getDataType() == schema::TENSOR) { + if (schemaField.getDataType() == schema::DataType::TENSOR) { *(dynamic_cast<TensorFieldValue *>(fvalue)) = std::move(val); } else { throw DocBuilder::Error(vespalib::make_string( @@ -91,7 +93,7 @@ insertPosition(const Schema::Field & sfield, document::FieldValue * fvalue, int32_t xpos, int32_t ypos) { assert(*fvalue->getDataType() == *DataType::LONG); - assert(sfield.getDataType() == schema::INT64); + assert(sfield.getDataType() == schema::DataType::INT64); (void) sfield; int64_t zpos = ZCurve::encode(xpos, ypos); document::LongFieldValue *zvalue = @@ -105,7 +107,7 @@ insertRaw(const Schema::Field & sfield, document::FieldValue *fvalue, const void *buf, size_t len) { assert(*fvalue->getDataType() == *DataType::RAW); - assert(sfield.getDataType() == schema::RAW); + assert(sfield.getDataType() == schema::DataType::RAW); (void) sfield; document::RawFieldValue *rfvalue = dynamic_cast<RawFieldValue *>(fvalue); @@ -197,11 +199,11 @@ DocBuilder::CollectionFieldHandle::startElement(int32_t weight) void DocBuilder::CollectionFieldHandle::endElement() { - if (_sfield.getCollectionType() == schema::ARRAY) { + if (_sfield.getCollectionType() == CollectionType::ARRAY) { onEndElement(); ArrayFieldValue * value = dynamic_cast<ArrayFieldValue *>(_value.get()); value->add(*_element); - } else if (_sfield.getCollectionType() == schema::WEIGHTEDSET) { + } else if (_sfield.getCollectionType() == CollectionType::WEIGHTEDSET) { onEndElement(); WeightedSetFieldValue * value = dynamic_cast<WeightedSetFieldValue *>(_value.get()); value->add(*_element, _elementWeight); @@ -229,7 +231,7 @@ DocBuilder::IndexFieldHandle::IndexFieldHandle(const FixedTypeRepo & repo, const { _str.reserve(1023); - if (_sfield.getCollectionType() == schema::SINGLE) { + if (_sfield.getCollectionType() == CollectionType::SINGLE) { if (*_value->getDataType() == document::UrlDataType::getInstance()) _uriField = true; } else { @@ -412,7 +414,7 @@ DocBuilder::IndexFieldHandle::onEndElement(void) if (_uriField) return; StringFieldValue * value; - if (_sfield.getCollectionType() != schema::SINGLE) { + if (_sfield.getCollectionType() != CollectionType::SINGLE) { value = dynamic_cast<StringFieldValue *>(_element.get()); } else { value = dynamic_cast<StringFieldValue *>(_value.get()); @@ -439,7 +441,7 @@ DocBuilder::IndexFieldHandle::onEndElement(void) void DocBuilder::IndexFieldHandle::onEndField(void) { - if (_sfield.getCollectionType() == schema::SINGLE) + if (_sfield.getCollectionType() == CollectionType::SINGLE) onEndElement(); } @@ -483,7 +485,7 @@ DocBuilder::IndexFieldHandle::endSubField(void) assert(!_subField.empty()); assert(_uriField); StructuredFieldValue *sValue; - if (_sfield.getCollectionType() != schema::SINGLE) { + if (_sfield.getCollectionType() != CollectionType::SINGLE) { sValue = dynamic_cast<StructFieldValue *>(_element.get()); } else { sValue = dynamic_cast<StructFieldValue *>(_value.get()); diff --git a/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp b/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp index 8b37645a306..cedc0372cd9 100644 --- a/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp +++ b/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp @@ -13,28 +13,28 @@ namespace { const DataType *convert(Schema::DataType type) { switch (type) { - case schema::UINT1: - case schema::UINT2: - case schema::UINT4: - case schema::INT8: + case schema::DataType::UINT1: + case schema::DataType::UINT2: + case schema::DataType::UINT4: + case schema::DataType::INT8: return DataType::BYTE; - case schema::INT16: + case schema::DataType::INT16: return DataType::SHORT; - case schema::INT32: + case schema::DataType::INT32: return DataType::INT; - case schema::INT64: + case schema::DataType::INT64: return DataType::LONG; - case schema::FLOAT: + case schema::DataType::FLOAT: return DataType::FLOAT; - case schema::DOUBLE: + case schema::DataType::DOUBLE: return DataType::DOUBLE; - case schema::STRING: + case schema::DataType::STRING: return DataType::STRING; - case schema::RAW: + case schema::DataType::RAW: return DataType::RAW; - case schema::BOOLEANTREE: + case schema::DataType::BOOLEANTREE: return DataType::PREDICATE; - case schema::TENSOR: + case schema::DataType::TENSOR: return DataType::TENSOR; default: break; @@ -88,7 +88,7 @@ DocTypeBuilder::UriField::valid(const Schema &schema, if (fieldId == Schema::UNKNOWN_FIELD_ID) return false; const Schema::IndexField &field = schema.getIndexField(fieldId); - if (field.getDataType() != schema::STRING) + if (field.getDataType() != schema::DataType::STRING) return false; if (field.getCollectionType() != collectionType) return false; @@ -209,7 +209,7 @@ DocTypeBuilder::SchemaIndexFields::setup(const Schema &schema) continue; const Schema::IndexField &field = schema.getIndexField(fieldId); switch (field.getDataType()) { - case schema::STRING: + case schema::DataType::STRING: _textFields.push_back(fieldId); break; default: @@ -230,9 +230,9 @@ using namespace document::config_builder; TypeOrId makeCollection(TypeOrId datatype, Schema::CollectionType collection_type) { switch (collection_type) { - case schema::ARRAY: + case schema::CollectionType::ARRAY: return Array(datatype); - case schema::WEIGHTEDSET: + case schema::CollectionType::WEIGHTEDSET: // TODO: consider using array of struct<primitive,int32> to keep order return Wset(datatype); default: @@ -241,11 +241,11 @@ TypeOrId makeCollection(TypeOrId datatype, } struct TypeCache { - std::map<std::pair<int, int>, TypeOrId> types; + std::map<std::pair<int, Schema::CollectionType>, TypeOrId> types; TypeOrId getType(TypeOrId datatype, Schema::CollectionType c_type) { TypeOrId type = makeCollection(datatype, c_type); - std::pair<int, int> key = std::make_pair(datatype.id, c_type); + std::pair<int, Schema::CollectionType> key = std::make_pair(datatype.id, c_type); if (types.find(key) == types.end()) { types.insert(std::make_pair(key, type)); } @@ -270,7 +270,7 @@ document::DocumenttypesConfig DocTypeBuilder::makeConfig() const { _schema.getIndexField(_iFields._textFields[i]); // only handles string fields for now - assert(field.getDataType() == schema::STRING); + assert(field.getDataType() == schema::DataType::STRING); header_struct.addField(field.getName(), type_cache.getType( DataType::T_STRING, field.getCollectionType())); header_struct.sstruct.field.back().id = field_id++; @@ -283,7 +283,7 @@ document::DocumenttypesConfig DocTypeBuilder::makeConfig() const { _schema.getIndexField(_iFields._uriFields[i]._all); // only handles string fields for now - assert(field.getDataType() == schema::STRING); + assert(field.getDataType() == schema::DataType::STRING); header_struct.addField(field.getName(), type_cache.getType( uri_type, field.getCollectionType())); header_struct.sstruct.field.back().id = field_id++; diff --git a/searchlib/src/vespa/searchlib/index/schemautil.cpp b/searchlib/src/vespa/searchlib/index/schemautil.cpp index 414ebe227d6..52c5a1caee4 100644 --- a/searchlib/src/vespa/searchlib/index/schemautil.cpp +++ b/searchlib/src/vespa/searchlib/index/schemautil.cpp @@ -11,12 +11,14 @@ namespace search { namespace index { +using schema::DataType; + SchemaUtil::IndexSettings SchemaUtil::getIndexSettings(const Schema &schema, const uint32_t index) { IndexSettings ret; - Schema::DataType indexDataType(schema::STRING); + Schema::DataType indexDataType(DataType::STRING); bool error = false; bool somePrefixes = false; bool someNotPrefixes = false; @@ -39,14 +41,9 @@ SchemaUtil::getIndexSettings(const Schema &schema, else someNotPositions = true; indexDataType = iField.getDataType(); - switch (indexDataType) { - case schema::STRING: - break; - default: + if (indexDataType != DataType::STRING) { error = true; - LOG(error, - "Field %s has bad data type", - iField.getName().c_str()); + LOG(error, "Field %s has bad data type", iField.getName().c_str()); } return IndexSettings(indexDataType, error, @@ -113,7 +110,7 @@ SchemaUtil::validateIndexField(const Schema::IndexField &field) field.getName().c_str()); ok = false; } - if (field.getDataType() != schema::STRING) { + if (field.getDataType() != DataType::STRING) { if (field.hasPrefix()) { LOG(error, "Field %s is non-string but has prefix", diff --git a/searchlib/src/vespa/searchlib/index/schemautil.h b/searchlib/src/vespa/searchlib/index/schemautil.h index d54e2c3e0f1..7c03886800e 100644 --- a/searchlib/src/vespa/searchlib/index/schemautil.h +++ b/searchlib/src/vespa/searchlib/index/schemautil.h @@ -31,7 +31,7 @@ public: bool hasPositions() const { return _positions; } IndexSettings() - : _dataType(schema::STRING), + : _dataType(schema::DataType::STRING), _error(false), _prefix(false), _phrases(false), @@ -151,8 +151,8 @@ public: static bool validateIndexFieldType(schema::DataType dataType) { switch (dataType) { - case schema::STRING: - case schema::INT32: + case schema::DataType::STRING: + case schema::DataType::INT32: return true; default: ; diff --git a/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.cpp b/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.cpp index 29a7c1ac274..859aff99c0a 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/fieldinverter.cpp @@ -22,29 +22,30 @@ namespace search { namespace memoryindex { -using document::Field; -using document::FieldValue; -using document::Document; +using document::AlternateSpanList; +using document::Annotation; +using document::AnnotationType; using document::ArrayFieldValue; -using document::WeightedSetFieldValue; -using document::StringFieldValue; -using document::IntFieldValue; -using document::StructFieldValue; using document::DataType; +using document::Document; using document::DocumentType; -using document::Annotation; -using document::AnnotationType; -using document::AlternateSpanList; +using document::Field; +using document::FieldValue; +using document::IntFieldValue; +using document::SimpleSpanList; using document::Span; using document::SpanList; -using document::SimpleSpanList; using document::SpanNode; using document::SpanTree; using document::SpanTreeVisitor; +using document::StringFieldValue; +using document::StructFieldValue; +using document::WeightedSetFieldValue; using index::DocIdAndPosOccFeatures; using index::Schema; -using vespalib::make_string; +using search::index::schema::CollectionType; using search::util::URL; +using vespalib::make_string; namespace documentinverterkludge { @@ -427,14 +428,14 @@ FieldInverter::invertNormalDocTextField(const FieldValue &val) const vespalib::Identifiable::RuntimeClass & cInfo(val.getClass()); const Schema::IndexField &field = _schema.getIndexField(_fieldId); switch (field.getCollectionType()) { - case index::schema::SINGLE: + case CollectionType::SINGLE: if (cInfo.id() == StringFieldValue::classId) { processNormalDocTextField(static_cast<const StringFieldValue &>(val)); } else { throw std::runtime_error(make_string("Expected DataType::STRING, got '%s'", val.getDataType()->getName().c_str())); } break; - case index::schema::WEIGHTEDSET: + case CollectionType::WEIGHTEDSET: if (cInfo.id() == WeightedSetFieldValue::classId) { const WeightedSetFieldValue &wset = static_cast<const WeightedSetFieldValue &>(val); if (wset.getNestedType() == *DataType::STRING) { @@ -446,7 +447,7 @@ FieldInverter::invertNormalDocTextField(const FieldValue &val) throw std::runtime_error(make_string("Expected weighted set, got '%s'", cInfo.name())); } break; - case index::schema::ARRAY: + case CollectionType::ARRAY: if (cInfo.id() == ArrayFieldValue::classId) { const ArrayFieldValue &arr = static_cast<const ArrayFieldValue&>(val); if (arr.getNestedType() == *DataType::STRING) { diff --git a/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.cpp b/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.cpp index 5629302804e..ab59718d064 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/urlfieldinverter.cpp @@ -56,6 +56,7 @@ using document::StructFieldValue; using document::UrlDataType; using document::WeightedSetFieldValue; using search::index::Schema; +using search::index::schema::CollectionType; using search::util::URL; using vespalib::make_string; @@ -304,7 +305,7 @@ UrlFieldInverter::invertUrlField(const FieldValue &val) { const vespalib::Identifiable::RuntimeClass & cInfo(val.getClass()); switch (_collectionType) { - case index::schema::SINGLE: + case CollectionType::SINGLE: if (isUriType(*val.getDataType())) { startElement(1); processUrlField(val); @@ -313,7 +314,7 @@ UrlFieldInverter::invertUrlField(const FieldValue &val) throw std::runtime_error(make_string("Expected URI struct, got '%s'", val.getDataType()->getName().c_str())); } break; - case index::schema::WEIGHTEDSET: + case CollectionType::WEIGHTEDSET: if (cInfo.id() == WeightedSetFieldValue::classId) { const WeightedSetFieldValue &wset = static_cast<const WeightedSetFieldValue &>(val); if (isUriType(wset.getNestedType())) { @@ -325,7 +326,7 @@ UrlFieldInverter::invertUrlField(const FieldValue &val) throw std::runtime_error(make_string("Expected weighted set, got '%s'", cInfo.name())); } break; - case index::schema::ARRAY: + case CollectionType::ARRAY: if (cInfo.id() == ArrayFieldValue::classId) { const ArrayFieldValue &arr = static_cast<const ArrayFieldValue&>(val); if (isUriType(arr.getNestedType())) { diff --git a/searchlib/src/vespa/searchlib/test/diskindex/testdiskindex.cpp b/searchlib/src/vespa/searchlib/test/diskindex/testdiskindex.cpp index 7b7a2fd8e61..006f7ee8207 100644 --- a/searchlib/src/vespa/searchlib/test/diskindex/testdiskindex.cpp +++ b/searchlib/src/vespa/searchlib/test/diskindex/testdiskindex.cpp @@ -7,9 +7,10 @@ namespace search { -using index::Schema; using index::DummyFileHeaderContext; +using index::Schema; using index::WordDocElementWordPosFeatures; +using index::schema::DataType; namespace diskindex { @@ -56,8 +57,8 @@ struct Builder void TestDiskIndex::buildSchema(void) { - _schema.addIndexField(Schema::IndexField("f1", index::schema::STRING)); - _schema.addIndexField(Schema::IndexField("f2", index::schema::STRING)); + _schema.addIndexField(Schema::IndexField("f1", DataType::STRING)); + _schema.addIndexField(Schema::IndexField("f2", DataType::STRING)); _schema.addFieldSet(Schema::FieldSet("c2"). addField("f1"). addField("f2")); diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp index b6a8b541344..8172fc68a43 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp @@ -13,6 +13,8 @@ namespace fakedata { using index::PostingListParams; using index::SchemaUtil; +using index::schema::CollectionType; +using index::schema::DataType; static void clearFakeWordVector(std::vector<FakeWord *> &v) @@ -63,14 +65,15 @@ FakeWordSet::setupParams(bool hasElements, _schema.clear(); assert(hasElements || !hasElementWeights); - Schema::CollectionType collectionType(index::schema::SINGLE); + Schema::CollectionType collectionType(CollectionType::SINGLE); if (hasElements) { - if (hasElementWeights) - collectionType = index::schema::WEIGHTEDSET; - else - collectionType = index::schema::ARRAY; + if (hasElementWeights) { + collectionType = CollectionType::WEIGHTEDSET; + } else { + collectionType = CollectionType::ARRAY; + } } - Schema::IndexField indexField("field0", index::schema::STRING, collectionType); + Schema::IndexField indexField("field0", DataType::STRING, collectionType); indexField.setAvgElemLen(512u); _schema.addIndexField(indexField); _fieldsParams.resize(_schema.getNumIndexFields()); |