diff options
55 files changed, 817 insertions, 721 deletions
diff --git a/searchcommon/src/tests/schema/schema_test.cpp b/searchcommon/src/tests/schema/schema_test.cpp index f399215dbda..1365de0fd96 100644 --- a/searchcommon/src/tests/schema/schema_test.cpp +++ b/searchcommon/src/tests/schema/schema_test.cpp @@ -13,6 +13,8 @@ using vespalib::string; namespace search { namespace index { +using schema::DataType; +using schema::CollectionType; using SIAF = Schema::ImportedAttributeField; void assertField(const Schema::Field & exp, const Schema::Field & act) { @@ -72,34 +74,34 @@ TEST("testBasic") { EXPECT_EQUAL(0u, s.getNumSummaryFields()); EXPECT_EQUAL(0u, s.getNumImportedAttributeFields()); - s.addIndexField(Schema::IndexField("foo", schema::STRING)); - s.addIndexField(Schema::IndexField("bar", schema::INT32)); + s.addIndexField(Schema::IndexField("foo", DataType::STRING)); + s.addIndexField(Schema::IndexField("bar", DataType::INT32)); - s.addAttributeField(Schema::AttributeField("foo", schema::STRING, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("bar", schema::INT32, schema::WEIGHTEDSET)); - s.addAttributeField(Schema::AttributeField("cox", schema::STRING)); + s.addAttributeField(Schema::AttributeField("foo", DataType::STRING, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("bar", DataType::INT32, CollectionType::WEIGHTEDSET)); + s.addAttributeField(Schema::AttributeField("cox", DataType::STRING)); - s.addSummaryField(Schema::SummaryField("foo", schema::STRING, schema::ARRAY)); - s.addSummaryField(Schema::SummaryField("bar", schema::INT32, schema::WEIGHTEDSET)); - s.addSummaryField(Schema::SummaryField("cox", schema::STRING)); - s.addSummaryField(Schema::SummaryField("fox", schema::RAW)); + s.addSummaryField(Schema::SummaryField("foo", DataType::STRING, CollectionType::ARRAY)); + s.addSummaryField(Schema::SummaryField("bar", DataType::INT32, CollectionType::WEIGHTEDSET)); + s.addSummaryField(Schema::SummaryField("cox", DataType::STRING)); + s.addSummaryField(Schema::SummaryField("fox", DataType::RAW)); s.addFieldSet(Schema::FieldSet("default").addField("foo").addField("bar")); - s.addImportedAttributeField(SIAF("imported", schema::INT32)); + s.addImportedAttributeField(SIAF("imported", DataType::INT32)); EXPECT_EQUAL(2u, s.getNumIndexFields()); { EXPECT_EQUAL("foo", s.getIndexField(0).getName()); - EXPECT_EQUAL(schema::STRING, s.getIndexField(0).getDataType()); - EXPECT_EQUAL(schema::SINGLE, s.getIndexField(0).getCollectionType()); + EXPECT_EQUAL(DataType::STRING, s.getIndexField(0).getDataType()); + EXPECT_EQUAL(CollectionType::SINGLE, s.getIndexField(0).getCollectionType()); EXPECT_TRUE(!s.getIndexField(0).hasPrefix()); EXPECT_TRUE(!s.getIndexField(0).hasPhrases()); EXPECT_TRUE(s.getIndexField(0).hasPositions()); EXPECT_EQUAL("bar", s.getIndexField(1).getName()); - EXPECT_EQUAL(schema::INT32, s.getIndexField(1).getDataType()); - EXPECT_EQUAL(schema::SINGLE, s.getIndexField(1).getCollectionType()); + EXPECT_EQUAL(DataType::INT32, s.getIndexField(1).getDataType()); + EXPECT_EQUAL(CollectionType::SINGLE, s.getIndexField(1).getCollectionType()); EXPECT_EQUAL(0u, s.getIndexFieldId("foo")); EXPECT_EQUAL(1u, s.getIndexFieldId("bar")); @@ -108,16 +110,16 @@ TEST("testBasic") { EXPECT_EQUAL(3u, s.getNumAttributeFields()); { EXPECT_EQUAL("foo", s.getAttributeField(0).getName()); - EXPECT_EQUAL(schema::STRING, s.getAttributeField(0).getDataType()); - EXPECT_EQUAL(schema::ARRAY, s.getAttributeField(0).getCollectionType()); + EXPECT_EQUAL(DataType::STRING, s.getAttributeField(0).getDataType()); + EXPECT_EQUAL(CollectionType::ARRAY, s.getAttributeField(0).getCollectionType()); EXPECT_EQUAL("bar", s.getAttributeField(1).getName()); - EXPECT_EQUAL(schema::INT32, s.getAttributeField(1).getDataType()); - EXPECT_EQUAL(schema::WEIGHTEDSET, s.getAttributeField(1).getCollectionType()); + EXPECT_EQUAL(DataType::INT32, s.getAttributeField(1).getDataType()); + EXPECT_EQUAL(CollectionType::WEIGHTEDSET, s.getAttributeField(1).getCollectionType()); EXPECT_EQUAL("cox", s.getAttributeField(2).getName()); - EXPECT_EQUAL(schema::STRING, s.getAttributeField(2).getDataType()); - EXPECT_EQUAL(schema::SINGLE, s.getAttributeField(2).getCollectionType()); + EXPECT_EQUAL(DataType::STRING, s.getAttributeField(2).getDataType()); + EXPECT_EQUAL(CollectionType::SINGLE, s.getAttributeField(2).getCollectionType()); EXPECT_EQUAL(0u, s.getAttributeFieldId("foo")); EXPECT_EQUAL(1u, s.getAttributeFieldId("bar")); @@ -127,20 +129,20 @@ TEST("testBasic") { EXPECT_EQUAL(4u, s.getNumSummaryFields()); { EXPECT_EQUAL("foo", s.getSummaryField(0).getName()); - EXPECT_EQUAL(schema::STRING, s.getSummaryField(0).getDataType()); - EXPECT_EQUAL(schema::ARRAY, s.getSummaryField(0).getCollectionType()); + EXPECT_EQUAL(DataType::STRING, s.getSummaryField(0).getDataType()); + EXPECT_EQUAL(CollectionType::ARRAY, s.getSummaryField(0).getCollectionType()); EXPECT_EQUAL("bar", s.getSummaryField(1).getName()); - EXPECT_EQUAL(schema::INT32, s.getSummaryField(1).getDataType()); - EXPECT_EQUAL(schema::WEIGHTEDSET, s.getSummaryField(1).getCollectionType()); + EXPECT_EQUAL(DataType::INT32, s.getSummaryField(1).getDataType()); + EXPECT_EQUAL(CollectionType::WEIGHTEDSET, s.getSummaryField(1).getCollectionType()); EXPECT_EQUAL("cox", s.getSummaryField(2).getName()); - EXPECT_EQUAL(schema::STRING, s.getSummaryField(2).getDataType()); - EXPECT_EQUAL(schema::SINGLE, s.getSummaryField(2).getCollectionType()); + EXPECT_EQUAL(DataType::STRING, s.getSummaryField(2).getDataType()); + EXPECT_EQUAL(CollectionType::SINGLE, s.getSummaryField(2).getCollectionType()); EXPECT_EQUAL("fox", s.getSummaryField(3).getName()); - EXPECT_EQUAL(schema::RAW, s.getSummaryField(3).getDataType()); - EXPECT_EQUAL(schema::SINGLE, s.getSummaryField(3).getCollectionType()); + EXPECT_EQUAL(DataType::RAW, s.getSummaryField(3).getDataType()); + EXPECT_EQUAL(CollectionType::SINGLE, s.getSummaryField(3).getCollectionType()); EXPECT_EQUAL(0u, s.getSummaryFieldId("foo")); EXPECT_EQUAL(1u, s.getSummaryFieldId("bar")); @@ -159,7 +161,7 @@ TEST("testBasic") { { const auto &imported = s.getImportedAttributeFields(); EXPECT_EQUAL(1u, imported.size()); - TEST_DO(assertField(SIAF("imported", schema::INT32, schema::SINGLE), imported[0])); + TEST_DO(assertField(SIAF("imported", DataType::INT32, CollectionType::SINGLE), imported[0])); } } @@ -219,7 +221,7 @@ TEST("testLoadAndSave") { EXPECT_TRUE(s3.loadFromFile("schema.txt")); assertSchema(s, s3); // test that saved file is loaded correctly s3.addIndexField(SIF("foo", SDT::STRING)); - s3.addImportedAttributeField(SIAF("imported", schema::INT32)); + s3.addImportedAttributeField(SIAF("imported", DataType::INT32)); EXPECT_TRUE(s3.loadFromFile("schema.txt")); // load should clear the current content assertSchema(s, s3); } @@ -228,7 +230,7 @@ TEST("testLoadAndSave") { EXPECT_TRUE(s.saveToFile("schema2.txt")); Schema s2; s2.addIndexField(SIF("foo", SDT::STRING)); - s2.addImportedAttributeField(SIAF("imported", schema::INT32)); + s2.addImportedAttributeField(SIAF("imported", DataType::INT32)); EXPECT_TRUE(s2.loadFromFile("schema2.txt")); assertSchema(s, s2); } @@ -243,7 +245,7 @@ TEST("require that schema can save and load timestamps for fields") { const fastos::TimeStamp timestamp(42); const std::string file_name = "schema-with-timestamps.txt"; Schema s; - Schema::IndexField f("foo", schema::STRING); + Schema::IndexField f("foo", DataType::STRING); f.setTimestamp(timestamp); s.addIndexField(f); ASSERT_TRUE(s.saveToFile(file_name)); @@ -256,7 +258,7 @@ TEST("require that schema can save and load timestamps for fields") { TEST("require that timestamps are omitted when 0.") { const std::string file_name = "schema-without-timestamps.txt"; Schema s; - s.addIndexField(Schema::IndexField("foo", schema::STRING)); + s.addIndexField(Schema::IndexField("foo", DataType::STRING)); ASSERT_TRUE(s.saveToFile(file_name)); std::ifstream file(file_name.c_str()); @@ -274,15 +276,15 @@ TEST("require that timestamps are omitted when 0.") { void addAllFieldTypes(const string &name, Schema &schema, fastos::TimeStamp timestamp) { - Schema::IndexField index_field(name, schema::STRING); + Schema::IndexField index_field(name, DataType::STRING); index_field.setTimestamp(timestamp); schema.addIndexField(index_field); - Schema::AttributeField attribute_field(name, schema::STRING); + Schema::AttributeField attribute_field(name, DataType::STRING); attribute_field.setTimestamp(timestamp); schema.addAttributeField(attribute_field); - Schema::SummaryField summary_field(name, schema::STRING); + Schema::SummaryField summary_field(name, DataType::STRING); summary_field.setTimestamp(timestamp); schema.addSummaryField(summary_field); @@ -387,9 +389,9 @@ TEST("require that schema can calculate intersection") { TEST("require that incompatible fields are removed from intersection") { const string name = "foo"; Schema s1; - s1.addIndexField(Schema::IndexField(name, schema::STRING)); + s1.addIndexField(Schema::IndexField(name, DataType::STRING)); Schema s2; - s2.addIndexField(Schema::IndexField(name, schema::INT32)); + s2.addIndexField(Schema::IndexField(name, DataType::INT32)); Schema::UP schema = Schema::intersect(s1, s2); EXPECT_EQUAL(0u, schema->getNumIndexFields()); EXPECT_FALSE(schema->isIndexField(name)); @@ -400,7 +402,7 @@ TEST("require that imported attribute fields are not saved to disk") const vespalib::string fileName = "schema-no-imported-fields.txt"; { Schema s; - s.addImportedAttributeField(Schema::ImportedAttributeField("imported", schema::INT32)); + s.addImportedAttributeField(Schema::ImportedAttributeField("imported", DataType::INT32)); s.saveToFile(fileName); } { @@ -416,8 +418,8 @@ TEST("require that schema can be built from imported-fields config") SchemaConfigurer configurer(s, "dir:" + TEST_PATH("imported-fields-cfg")); const auto &imported = s.getImportedAttributeFields(); EXPECT_EQUAL(2u, imported.size()); - TEST_DO(assertField(SIAF("imported_a", schema::STRING, schema::SINGLE), imported[0])); - TEST_DO(assertField(SIAF("imported_b", schema::STRING, schema::SINGLE), imported[1])); + TEST_DO(assertField(SIAF("imported_a", DataType::STRING, CollectionType::SINGLE), imported[0])); + TEST_DO(assertField(SIAF("imported_b", DataType::STRING, CollectionType::SINGLE), imported[1])); } } // namespace index diff --git a/searchcommon/src/vespa/searchcommon/common/datatype.cpp b/searchcommon/src/vespa/searchcommon/common/datatype.cpp index b28fc06b3fd..ef6dcfc3ad6 100644 --- a/searchcommon/src/vespa/searchcommon/common/datatype.cpp +++ b/searchcommon/src/vespa/searchcommon/common/datatype.cpp @@ -13,20 +13,20 @@ using config::InvalidConfigException; DataType dataTypeFromName(const vespalib::stringref &name) { - if (name == "UINT1") { return UINT1; } - else if (name == "UINT2") { return UINT2; } - else if (name == "UINT4") { return UINT4; } - else if (name == "INT8") { return INT8; } - else if (name == "INT16") { return INT16; } - else if (name == "INT32") { return INT32; } - else if (name == "INT64") { return INT64; } - else if (name == "FLOAT") { return FLOAT; } - else if (name == "DOUBLE") { return DOUBLE; } - else if (name == "STRING") { return STRING; } - else if (name == "RAW") { return RAW; } - else if (name == "BOOLEANTREE") { return BOOLEANTREE; } - else if (name == "TENSOR") { return TENSOR; } - else if (name == "REFERENCE") { return REFERENCE; } + if (name == "UINT1") { return DataType::UINT1; } + else if (name == "UINT2") { return DataType::UINT2; } + else if (name == "UINT4") { return DataType::UINT4; } + else if (name == "INT8") { return DataType::INT8; } + else if (name == "INT16") { return DataType::INT16; } + else if (name == "INT32") { return DataType::INT32; } + else if (name == "INT64") { return DataType::INT64; } + else if (name == "FLOAT") { return DataType::FLOAT; } + else if (name == "DOUBLE") { return DataType::DOUBLE; } + else if (name == "STRING") { return DataType::STRING; } + else if (name == "RAW") { return DataType::RAW; } + else if (name == "BOOLEANTREE") { return DataType::BOOLEANTREE; } + else if (name == "TENSOR") { return DataType::TENSOR; } + else if (name == "REFERENCE") { return DataType::REFERENCE; } else { throw InvalidConfigException("Illegal enum value '" + name + "'"); } @@ -50,19 +50,26 @@ const char *datatype_str[] = { "UINT1", vespalib::string getTypeName(DataType type) { - if (type > vespalib::arraysize(datatype_str)) { + if (static_cast<size_t>(type) > vespalib::arraysize(datatype_str)) { vespalib::asciistream ost; - ost << "UNKNOWN(" << type << ")"; + ost << "UNKNOWN(" << static_cast<size_t>(type) << ")"; return ost.str(); } - return datatype_str[type]; + return datatype_str[static_cast<size_t>(type)]; +} + +std::ostream & +operator<<(std::ostream &os, const DataType &type) +{ + os << getTypeName(type); + return os; } CollectionType collectionTypeFromName(const vespalib::stringref &name) { - if (name == "SINGLE") { return SINGLE; } - else if (name == "ARRAY") { return ARRAY; } - else if (name == "WEIGHTEDSET") { return WEIGHTEDSET; } + if (name == "SINGLE") { return CollectionType::SINGLE; } + else if (name == "ARRAY") { return CollectionType::ARRAY; } + else if (name == "WEIGHTEDSET") { return CollectionType::WEIGHTEDSET; } else { throw InvalidConfigException("Illegal enum value '" + name + "'"); } @@ -74,14 +81,20 @@ const char *collectiontype_str[] = { "SINGLE", vespalib::string getTypeName(CollectionType type) { - if (type > vespalib::arraysize(collectiontype_str)) { + if (static_cast<size_t>(type) > vespalib::arraysize(collectiontype_str)) { vespalib::asciistream ost; - ost << "UNKNOWN(" << type << ")"; + ost << "UNKNOWN(" << static_cast<size_t>(type) << ")"; return ost.str(); } - return collectiontype_str[type]; + return collectiontype_str[static_cast<size_t>(type)]; } +std::ostream & +operator<<(std::ostream &os, const CollectionType &type) +{ + os << getTypeName(type); + return os; +} } } diff --git a/searchcommon/src/vespa/searchcommon/common/datatype.h b/searchcommon/src/vespa/searchcommon/common/datatype.h index f73274d58c0..1570bfdb688 100644 --- a/searchcommon/src/vespa/searchcommon/common/datatype.h +++ b/searchcommon/src/vespa/searchcommon/common/datatype.h @@ -11,7 +11,7 @@ namespace schema { /** * Basic data type for a field. **/ -enum DataType { UINT1 = 0, +enum class DataType { UINT1 = 0, UINT2 = 1, UINT4 = 2, INT8 = 3, @@ -31,15 +31,19 @@ enum DataType { UINT1 = 0, /** * Collection type for a field. **/ -enum CollectionType { SINGLE = 0, +enum class CollectionType { SINGLE = 0, ARRAY = 1, WEIGHTEDSET = 2 }; DataType dataTypeFromName(const vespalib::stringref &name); vespalib::string getTypeName(DataType type); +std::ostream &operator<<(std::ostream &os, const DataType &type); + CollectionType collectionTypeFromName(const vespalib::stringref &n); vespalib::string getTypeName(CollectionType type); +std::ostream &operator<<(std::ostream &os, const CollectionType &type); + } } diff --git a/searchcommon/src/vespa/searchcommon/common/schema.cpp b/searchcommon/src/vespa/searchcommon/common/schema.cpp index f2e64cd943e..720b4572fa8 100644 --- a/searchcommon/src/vespa/searchcommon/common/schema.cpp +++ b/searchcommon/src/vespa/searchcommon/common/schema.cpp @@ -72,7 +72,7 @@ const uint32_t Schema::UNKNOWN_FIELD_ID(std::numeric_limits<uint32_t>::max()); Schema::Field::Field(const vespalib::stringref &n, DataType dt) : _name(n), _dataType(dt), - _collectionType(schema::SINGLE), + _collectionType(schema::CollectionType::SINGLE), _timestamp(0) { } diff --git a/searchcommon/src/vespa/searchcommon/common/schemaconfigurer.cpp b/searchcommon/src/vespa/searchcommon/common/schemaconfigurer.cpp index 195483855cd..cc6d1f972f6 100644 --- a/searchcommon/src/vespa/searchcommon/common/schemaconfigurer.cpp +++ b/searchcommon/src/vespa/searchcommon/common/schemaconfigurer.cpp @@ -12,19 +12,21 @@ using namespace vespa::config::search; namespace search { namespace index { +using schema::DataType; +using schema::CollectionType; Schema::DataType SchemaBuilder::convert(const IndexschemaConfig::Indexfield::Datatype &type) { switch (type) { case IndexschemaConfig::Indexfield::STRING: - return schema::STRING; + return DataType::STRING; case IndexschemaConfig::Indexfield::INT64: - return schema::INT64; + return DataType::INT64; case IndexschemaConfig::Indexfield::BOOLEANTREE: - return schema::BOOLEANTREE; + return DataType::BOOLEANTREE; } - return schema::STRING; + return DataType::STRING; } @@ -33,13 +35,13 @@ SchemaBuilder::convert(const IndexschemaConfig::Indexfield::Collectiontype & typ { switch (type) { case IndexschemaConfig::Indexfield::SINGLE: - return schema::SINGLE; + return CollectionType::SINGLE; case IndexschemaConfig::Indexfield::ARRAY: - return schema::ARRAY; + return CollectionType::ARRAY; case IndexschemaConfig::Indexfield::WEIGHTEDSET: - return schema::WEIGHTEDSET; + return CollectionType::WEIGHTEDSET; } - return schema::SINGLE; + return CollectionType::SINGLE; } @@ -48,36 +50,36 @@ SchemaBuilder::convert(const AttributesConfig::Attribute::Datatype &type) { switch (type) { case AttributesConfig::Attribute::STRING: - return schema::STRING; + return DataType::STRING; case AttributesConfig::Attribute::UINT1: - return schema::UINT1; + return DataType::UINT1; case AttributesConfig::Attribute::UINT2: - return schema::UINT2; + return DataType::UINT2; case AttributesConfig::Attribute::UINT4: - return schema::UINT4; + return DataType::UINT4; case AttributesConfig::Attribute::INT8: - return schema::INT8; + return DataType::INT8; case AttributesConfig::Attribute::INT16: - return schema::INT16; + return DataType::INT16; case AttributesConfig::Attribute::INT32: - return schema::INT32; + return DataType::INT32; case AttributesConfig::Attribute::INT64: - return schema::INT64; + return DataType::INT64; case AttributesConfig::Attribute::FLOAT: - return schema::FLOAT; + return DataType::FLOAT; case AttributesConfig::Attribute::DOUBLE: - return schema::DOUBLE; + return DataType::DOUBLE; case AttributesConfig::Attribute::PREDICATE: - return schema::BOOLEANTREE; + return DataType::BOOLEANTREE; case AttributesConfig::Attribute::TENSOR: - return schema::TENSOR; + return DataType::TENSOR; case AttributesConfig::Attribute::REFERENCE: - return schema::REFERENCE; + return DataType::REFERENCE; default: break; } // TODO: exception? - return schema::STRING; + return DataType::STRING; } @@ -86,13 +88,13 @@ SchemaBuilder::convert(const AttributesConfig::Attribute::Collectiontype &type) { switch (type) { case AttributesConfig::Attribute::SINGLE: - return schema::SINGLE; + return CollectionType::SINGLE; case AttributesConfig::Attribute::ARRAY: - return schema::ARRAY; + return CollectionType::ARRAY; case AttributesConfig::Attribute::WEIGHTEDSET: - return schema::WEIGHTEDSET; + return CollectionType::WEIGHTEDSET; } - return schema::SINGLE; + return CollectionType::SINGLE; } @@ -100,30 +102,30 @@ Schema::DataType SchemaBuilder::convertSummaryType(const vespalib::string & type) { if (type == "byte") { - return schema::INT8; + return DataType::INT8; } else if (type == "short") { - return schema::INT16; + return DataType::INT16; } else if (type == "integer") { - return schema::INT32; + return DataType::INT32; } else if (type == "int64") { - return schema::INT64; + return DataType::INT64; } else if (type == "float") { - return schema::FLOAT; + return DataType::FLOAT; } else if (type == "double") { - return schema::DOUBLE; + return DataType::DOUBLE; } else if (type == "string" || type == "longstring" || type == "xmlstring" || type == "featuredata" || type == "jsonstring") { - return schema::STRING; + return DataType::STRING; } else if (type == "data" || type == "longdata") { - return schema::RAW; + return DataType::RAW; } - return schema::RAW; + return DataType::RAW; } diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp index 526358f65f5..57aa987ada2 100644 --- a/searchcore/src/tests/proton/attribute/attribute_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp @@ -40,18 +40,20 @@ LOG_SETUP("attribute_test"); namespace vespa { namespace config { namespace search {}}} -using std::string; -using namespace vespa::config::search; using namespace config; using namespace document; using namespace proton; -using namespace search; using namespace search::index; -using search::tensor::TensorAttribute; +using namespace search; +using namespace vespa::config::search; + using search::TuneFileAttributes; using search::index::DummyFileHeaderContext; -using search::predicate::PredicateIndex; +using search::index::schema::CollectionType; using search::predicate::PredicateHash; +using search::predicate::PredicateIndex; +using search::tensor::TensorAttribute; +using std::string; using vespalib::eval::ValueType; using vespalib::tensor::Tensor; using vespalib::tensor::TensorCells; @@ -139,10 +141,10 @@ struct Fixture TEST_F("require that attribute adapter handles put", Fixture) { Schema s; - s.addAttributeField(Schema::AttributeField("a1", schema::INT32, schema::SINGLE)); - s.addAttributeField(Schema::AttributeField("a2", schema::INT32, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("a3", schema::FLOAT, schema::SINGLE)); - s.addAttributeField(Schema::AttributeField("a4", schema::STRING, schema::SINGLE)); + s.addAttributeField(Schema::AttributeField("a1", schema::DataType::INT32, CollectionType::SINGLE)); + s.addAttributeField(Schema::AttributeField("a2", schema::DataType::INT32, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("a3", schema::DataType::FLOAT, CollectionType::SINGLE)); + s.addAttributeField(Schema::AttributeField("a4", schema::DataType::STRING, CollectionType::SINGLE)); DocBuilder idb(s); @@ -233,7 +235,7 @@ TEST_F("require that attribute adapter handles put", Fixture) TEST_F("require that attribute adapter handles predicate put", Fixture) { Schema s; - s.addAttributeField(Schema::AttributeField("a1", schema::BOOLEANTREE, schema::SINGLE)); + s.addAttributeField(Schema::AttributeField("a1", schema::DataType::BOOLEANTREE, CollectionType::SINGLE)); DocBuilder idb(s); proton::AttributeManager & am = *f._m; @@ -281,8 +283,8 @@ TEST_F("require that attribute adapter handles remove", Fixture) AttributeVector::SP a1 = f.addAttribute("a1"); AttributeVector::SP a2 = f.addAttribute("a2"); Schema s; - s.addAttributeField(Schema::AttributeField("a1", schema::INT32, schema::SINGLE)); - s.addAttributeField(Schema::AttributeField("a2", schema::INT32, schema::SINGLE)); + s.addAttributeField(Schema::AttributeField("a1", schema::DataType::INT32, CollectionType::SINGLE)); + s.addAttributeField(Schema::AttributeField("a2", schema::DataType::INT32, CollectionType::SINGLE)); DocBuilder idb(s); @@ -319,7 +321,7 @@ TEST_F("require that visibilitydelay is honoured", Fixture) AVConfig(AVBasicType::STRING), createSerialNum); Schema s; - s.addAttributeField(Schema::AttributeField("a1", schema::STRING, schema::SINGLE)); + s.addAttributeField(Schema::AttributeField("a1", schema::DataType::STRING, CollectionType::SINGLE)); DocBuilder idb(s); EXPECT_EQUAL(1u, a1->getNumDocs()); EXPECT_EQUAL(0u, a1->getStatus().getLastSyncToken()); @@ -369,7 +371,7 @@ TEST_F("require that attribute adapter handles predicate remove", Fixture) createSerialNum); Schema s; s.addAttributeField( - Schema::AttributeField("a1", schema::BOOLEANTREE, schema::SINGLE)); + Schema::AttributeField("a1", schema::DataType::BOOLEANTREE, CollectionType::SINGLE)); DocBuilder idb(s); PredicateSlimeBuilder builder; @@ -395,8 +397,8 @@ TEST_F("require that attribute adapter handles update", Fixture) fillAttribute(a2, 1, 20, 1); Schema schema; - schema.addAttributeField(Schema::AttributeField("a1", schema::INT32, schema::SINGLE)); - schema.addAttributeField(Schema::AttributeField("a2", schema::INT32, schema::SINGLE)); + schema.addAttributeField(Schema::AttributeField("a1", schema::DataType::INT32, CollectionType::SINGLE)); + schema.addAttributeField(Schema::AttributeField("a2", schema::DataType::INT32, CollectionType::SINGLE)); DocBuilder idb(schema); const document::DocumentType &dt(idb.getDocumentType()); DocumentUpdate upd(dt, DocumentId("doc::1")); @@ -433,7 +435,7 @@ TEST_F("require that attribute adapter handles predicate update", Fixture) AVConfig(AVBasicType::PREDICATE), createSerialNum); Schema schema; - schema.addAttributeField(Schema::AttributeField("a1", schema::BOOLEANTREE, schema::SINGLE)); + schema.addAttributeField(Schema::AttributeField("a1", schema::DataType::BOOLEANTREE, CollectionType::SINGLE)); DocBuilder idb(schema); PredicateSlimeBuilder builder; @@ -577,7 +579,7 @@ createTensorAttribute(Fixture &f) { Schema createTensorSchema() { Schema schema; - schema.addAttributeField(Schema::AttributeField("a1", schema::TENSOR, schema::SINGLE)); + schema.addAttributeField(Schema::AttributeField("a1", schema::DataType::TENSOR, CollectionType::SINGLE)); return schema; } diff --git a/searchcore/src/tests/proton/common/cachedselect_test.cpp b/searchcore/src/tests/proton/common/cachedselect_test.cpp index da549cc7be0..d82eaa747db 100644 --- a/searchcore/src/tests/proton/common/cachedselect_test.cpp +++ b/searchcore/src/tests/proton/common/cachedselect_test.cpp @@ -27,39 +27,40 @@ #include <vespa/log/log.h> LOG_SETUP("cachedselect_test"); -using search::index::Schema; -using document::DocumentTypeRepo; -using document::DocumentType; -using document::select::Node; -using document::select::Result; -using document::select::ResultSet; -using document::select::CloningVisitor; -using document::select::Context; -using vespalib::string; - -using document::config_builder::DocumenttypesConfigBuilderHelper; -using document::config_builder::Struct; -using document::config_builder::Array; -using document::config_builder::Wset; -using document::config_builder::Map; using document::DataType; using document::Document; using document::DocumentId; -using document::StringFieldValue; +using document::DocumentType; +using document::DocumentTypeRepo; using document::IntFieldValue; +using document::StringFieldValue; +using document::config_builder::Array; +using document::config_builder::DocumenttypesConfigBuilderHelper; +using document::config_builder::Map; +using document::config_builder::Struct; +using document::config_builder::Wset; +using document::select::CloningVisitor; +using document::select::Context; +using document::select::Node; +using document::select::Result; +using document::select::ResultSet; using proton::CachedSelect; using proton::SelectContext; -using search::AttributeVector; -using search::AttributeGuard; -using search::AttributeEnumGuard; using search::AttributeContext; -using search::EnumAttribute; +using search::AttributeEnumGuard; +using search::AttributeGuard; using search::AttributePosting; -using search::SingleValueNumericPostingAttribute; +using search::AttributeVector; +using search::EnumAttribute; using search::IntegerAttribute; using search::IntegerAttributeTemplate; +using search::SingleValueNumericPostingAttribute; using search::attribute::IAttributeContext; using search::attribute::test::MockAttributeManager; +using search::index::Schema; +using search::index::schema::CollectionType; +using vespalib::string; + using namespace search::index; typedef Node::UP NodeUP; @@ -77,10 +78,10 @@ namespace { void makeSchema(Schema &s) { - s.addIndexField(Schema::IndexField("ia", schema::STRING)); - s.addAttributeField(Schema::AttributeField("aa", schema::INT32)); - s.addAttributeField(Schema::AttributeField("aaa", schema::INT32, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("aaw", schema::INT32, schema::WEIGHTEDSET)); + s.addIndexField(Schema::IndexField("ia", schema::DataType::STRING)); + s.addAttributeField(Schema::AttributeField("aa", schema::DataType::INT32)); + s.addAttributeField(Schema::AttributeField("aaa", schema::DataType::INT32, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("aaw", schema::DataType::INT32, CollectionType::WEIGHTEDSET)); } const int32_t doc_type_id = 787121340; diff --git a/searchcore/src/tests/proton/common/schemautil_test.cpp b/searchcore/src/tests/proton/common/schemautil_test.cpp index 465c7a2a3b0..d21582c5111 100644 --- a/searchcore/src/tests/proton/common/schemautil_test.cpp +++ b/searchcore/src/tests/proton/common/schemautil_test.cpp @@ -6,25 +6,27 @@ #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/testkit/testapp.h> +using namespace proton; using namespace search::index; +using search::index::schema::CollectionType; +using search::index::schema::DataType; using vespalib::string; -using namespace proton; namespace { void addAllFieldTypes(const string &name, Schema &schema, fastos::TimeStamp timestamp) { - Schema::IndexField index_field(name, schema::STRING); + Schema::IndexField index_field(name, DataType::STRING); index_field.setTimestamp(timestamp); schema.addIndexField(index_field); - Schema::AttributeField attribute_field(name, schema::STRING); + Schema::AttributeField attribute_field(name, DataType::STRING); attribute_field.setTimestamp(timestamp); schema.addAttributeField(attribute_field); - Schema::SummaryField summary_field(name, schema::STRING); + Schema::SummaryField summary_field(name, DataType::STRING); summary_field.setTimestamp(timestamp); schema.addSummaryField(summary_field); } @@ -109,9 +111,9 @@ assertSchemaResult(const vespalib::string &name, TEST("require that listSchema can list all fields") { Schema schema; - schema.addIndexField(Schema::IndexField("if", schema::STRING)); - schema.addAttributeField(Schema::AttributeField("af", schema::INT32)); - schema.addSummaryField(Schema::SummaryField("sf", schema::FLOAT, schema::ARRAY)); + schema.addIndexField(Schema::IndexField("if", DataType::STRING)); + schema.addAttributeField(Schema::AttributeField("af", DataType::INT32)); + schema.addSummaryField(Schema::SummaryField("sf", DataType::FLOAT, CollectionType::ARRAY)); ListSchemaResult r; SchemaUtil::listSchema(schema, r.fieldNames, r.fieldDataTypes, r.fieldCollectionTypes, r.fieldLocations); diff --git a/searchcore/src/tests/proton/common/selectpruner_test.cpp b/searchcore/src/tests/proton/common/selectpruner_test.cpp index 7bea3ee12e0..7199cda27d6 100644 --- a/searchcore/src/tests/proton/common/selectpruner_test.cpp +++ b/searchcore/src/tests/proton/common/selectpruner_test.cpp @@ -12,22 +12,22 @@ LOG_SETUP("selectpruner_test"); using namespace search::index; -using document::DocumentTypeRepo; +using document::DataType; +using document::Document; using document::DocumentType; -using document::select::Node; -using document::select::Result; -using document::select::ResultSet; -using document::select::CloningVisitor; -using vespalib::string; - +using document::DocumentTypeRepo; +using document::config_builder::Array; using document::config_builder::DocumenttypesConfigBuilderHelper; +using document::config_builder::Map; using document::config_builder::Struct; -using document::config_builder::Array; using document::config_builder::Wset; -using document::config_builder::Map; -using document::DataType; -using document::Document; +using document::select::CloningVisitor; +using document::select::Node; +using document::select::Result; +using document::select::ResultSet; using proton::SelectPruner; +using search::index::schema::CollectionType; +using vespalib::string; typedef Node::UP NodeUP; @@ -37,12 +37,12 @@ namespace void makeSchema(Schema &s) { - s.addIndexField(Schema::IndexField("ia", schema::STRING)); - s.addAttributeField(Schema::AttributeField("aa", schema::INT32)); - s.addAttributeField(Schema::AttributeField("aaa", schema::INT32, - schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("aaw", schema::INT32, - schema::WEIGHTEDSET)); + s.addIndexField(Schema::IndexField("ia", schema::DataType::STRING)); + s.addAttributeField(Schema::AttributeField("aa", schema::DataType::INT32)); + s.addAttributeField(Schema::AttributeField("aaa", schema::DataType::INT32, + CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("aaw", schema::DataType::INT32, + CollectionType::WEIGHTEDSET)); } const int32_t doc_type_id = 787121340; diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index 411730ce188..05f335f374c 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -29,17 +29,19 @@ #include <vespa/log/log.h> LOG_SETUP("docsummary_test"); +using namespace cloud::config::filedistribution; using namespace document; -using namespace search; using namespace search::docsummary; using namespace search::engine; using namespace search::index; using namespace search::transactionlog; -using namespace cloud::config::filedistribution; -using search::TuneFileDocumentDB; +using namespace search; + using document::DocumenttypesConfig; -using storage::spi::Timestamp; +using search::TuneFileDocumentDB; using search::index::DummyFileHeaderContext; +using search::index::schema::CollectionType; +using storage::spi::Timestamp; using vespa::config::search::core::ProtonConfig; using vespalib::tensor::Tensor; using vespalib::tensor::TensorCells; @@ -490,18 +492,18 @@ void Test::requireThatAdapterHandlesAllFieldTypes() { Schema s; - s.addSummaryField(Schema::SummaryField("a", schema::INT8)); - s.addSummaryField(Schema::SummaryField("b", schema::INT16)); - s.addSummaryField(Schema::SummaryField("c", schema::INT32)); - s.addSummaryField(Schema::SummaryField("d", schema::INT64)); - s.addSummaryField(Schema::SummaryField("e", schema::FLOAT)); - s.addSummaryField(Schema::SummaryField("f", schema::DOUBLE)); - s.addSummaryField(Schema::SummaryField("g", schema::STRING)); - s.addSummaryField(Schema::SummaryField("h", schema::STRING)); - s.addSummaryField(Schema::SummaryField("i", schema::RAW)); - s.addSummaryField(Schema::SummaryField("j", schema::RAW)); - s.addSummaryField(Schema::SummaryField("k", schema::STRING)); - s.addSummaryField(Schema::SummaryField("l", schema::STRING)); + s.addSummaryField(Schema::SummaryField("a", schema::DataType::INT8)); + s.addSummaryField(Schema::SummaryField("b", schema::DataType::INT16)); + s.addSummaryField(Schema::SummaryField("c", schema::DataType::INT32)); + s.addSummaryField(Schema::SummaryField("d", schema::DataType::INT64)); + s.addSummaryField(Schema::SummaryField("e", schema::DataType::FLOAT)); + s.addSummaryField(Schema::SummaryField("f", schema::DataType::DOUBLE)); + s.addSummaryField(Schema::SummaryField("g", schema::DataType::STRING)); + s.addSummaryField(Schema::SummaryField("h", schema::DataType::STRING)); + s.addSummaryField(Schema::SummaryField("i", schema::DataType::RAW)); + s.addSummaryField(Schema::SummaryField("j", schema::DataType::RAW)); + s.addSummaryField(Schema::SummaryField("k", schema::DataType::STRING)); + s.addSummaryField(Schema::SummaryField("l", schema::DataType::STRING)); BuildContext bc(s); bc._bld.startDocument("doc::0"); @@ -550,7 +552,7 @@ void Test::requireThatAdapterHandlesMultipleDocuments() { Schema s; - s.addSummaryField(Schema::SummaryField("a", schema::INT32)); + s.addSummaryField(Schema::SummaryField("a", schema::DataType::INT32)); BuildContext bc(s); bc._bld.startDocument("doc::0"). @@ -592,7 +594,7 @@ void Test::requireThatAdapterHandlesDocumentIdField() { Schema s; - s.addSummaryField(Schema::SummaryField("documentid", schema::STRING)); + s.addSummaryField(Schema::SummaryField("documentid", schema::DataType::STRING)); BuildContext bc(s); bc._bld.startDocument("doc::0"). startSummaryField("documentid"). @@ -619,7 +621,7 @@ void Test::requireThatDocsumRequestIsProcessed() { Schema s; - s.addSummaryField(Schema::SummaryField("a", schema::INT32)); + s.addSummaryField(Schema::SummaryField("a", schema::DataType::INT32)); BuildContext bc(s); DBContext dc(bc._repo, getDocTypeName()); @@ -678,8 +680,8 @@ void Test::requireThatRewritersAreUsed() { Schema s; - s.addSummaryField(Schema::SummaryField("aa", schema::INT32)); - s.addSummaryField(Schema::SummaryField("ab", schema::INT32)); + s.addSummaryField(Schema::SummaryField("aa", schema::DataType::INT32)); + s.addSummaryField(Schema::SummaryField("ab", schema::DataType::INT32)); BuildContext bc(s); DBContext dc(bc._repo, getDocTypeName()); @@ -717,16 +719,16 @@ void Test::requireThatAttributesAreUsed() { Schema s; - addField(s, "ba", schema::INT32, schema::SINGLE); - addField(s, "bb", schema::FLOAT, schema::SINGLE); - addField(s, "bc", schema::STRING, schema::SINGLE); - addField(s, "bd", schema::INT32, schema::ARRAY); - addField(s, "be", schema::FLOAT, schema::ARRAY); - addField(s, "bf", schema::STRING, schema::ARRAY); - addField(s, "bg", schema::INT32, schema::WEIGHTEDSET); - addField(s, "bh", schema::FLOAT, schema::WEIGHTEDSET); - addField(s, "bi", schema::STRING, schema::WEIGHTEDSET); - addField(s, "bj", schema::TENSOR, schema::SINGLE); + addField(s, "ba", schema::DataType::INT32, CollectionType::SINGLE); + addField(s, "bb", schema::DataType::FLOAT, CollectionType::SINGLE); + addField(s, "bc", schema::DataType::STRING, CollectionType::SINGLE); + addField(s, "bd", schema::DataType::INT32, CollectionType::ARRAY); + addField(s, "be", schema::DataType::FLOAT, CollectionType::ARRAY); + addField(s, "bf", schema::DataType::STRING, CollectionType::ARRAY); + addField(s, "bg", schema::DataType::INT32, CollectionType::WEIGHTEDSET); + addField(s, "bh", schema::DataType::FLOAT, CollectionType::WEIGHTEDSET); + addField(s, "bi", schema::DataType::STRING, CollectionType::WEIGHTEDSET); + addField(s, "bj", schema::DataType::TENSOR, CollectionType::SINGLE); BuildContext bc(s); DBContext dc(bc._repo, getDocTypeName()); @@ -866,7 +868,7 @@ void Test::requireThatSummaryAdapterHandlesPutAndRemove() { Schema s; - s.addSummaryField(Schema::SummaryField("f1", schema::STRING, schema::SINGLE)); + s.addSummaryField(Schema::SummaryField("f1", schema::DataType::STRING, CollectionType::SINGLE)); BuildContext bc(s); DBContext dc(bc._repo, getDocTypeName()); Document::UP exp = bc._bld.startDocument("doc::1"). @@ -900,10 +902,10 @@ void Test::requireThatAnnotationsAreUsed() { Schema s; - s.addIndexField(Schema::IndexField("g", schema::STRING, schema::SINGLE)); - s.addSummaryField(Schema::SummaryField("g", schema::STRING, schema::SINGLE)); - s.addIndexField(Schema::IndexField("dynamicstring", schema::STRING, schema::SINGLE)); - s.addSummaryField(Schema::SummaryField("dynamicstring", schema::STRING, schema::SINGLE)); + s.addIndexField(Schema::IndexField("g", schema::DataType::STRING, CollectionType::SINGLE)); + s.addSummaryField(Schema::SummaryField("g", schema::DataType::STRING, CollectionType::SINGLE)); + s.addIndexField(Schema::IndexField("dynamicstring", schema::DataType::STRING, CollectionType::SINGLE)); + s.addSummaryField(Schema::SummaryField("dynamicstring", schema::DataType::STRING, CollectionType::SINGLE)); BuildContext bc(s); DBContext dc(bc._repo, getDocTypeName()); Document::UP exp = bc._bld.startDocument("doc::0"). @@ -953,12 +955,12 @@ void Test::requireThatUrisAreUsed() { Schema s; - s.addUriIndexFields(Schema::IndexField("urisingle", schema::STRING, schema::SINGLE)); - s.addSummaryField(Schema::SummaryField("urisingle", schema::STRING, schema::SINGLE)); - s.addUriIndexFields(Schema::IndexField("uriarray", schema::STRING, schema::ARRAY)); - s.addSummaryField(Schema::SummaryField("uriarray", schema::STRING, schema::ARRAY)); - s.addUriIndexFields(Schema::IndexField("uriwset", schema::STRING, schema::WEIGHTEDSET)); - s.addSummaryField(Schema::SummaryField("uriwset", schema::STRING, schema::WEIGHTEDSET)); + s.addUriIndexFields(Schema::IndexField("urisingle", schema::DataType::STRING, CollectionType::SINGLE)); + s.addSummaryField(Schema::SummaryField("urisingle", schema::DataType::STRING, CollectionType::SINGLE)); + s.addUriIndexFields(Schema::IndexField("uriarray", schema::DataType::STRING, CollectionType::ARRAY)); + s.addSummaryField(Schema::SummaryField("uriarray", schema::DataType::STRING, CollectionType::ARRAY)); + s.addUriIndexFields(Schema::IndexField("uriwset", schema::DataType::STRING, CollectionType::WEIGHTEDSET)); + s.addSummaryField(Schema::SummaryField("uriwset", schema::DataType::STRING, CollectionType::WEIGHTEDSET)); BuildContext bc(s); DBContext dc(bc._repo, getDocTypeName()); Document::UP exp = bc._bld.startDocument("doc::0"). @@ -1127,9 +1129,9 @@ void Test::requireThatPositionsAreUsed() { Schema s; - s.addAttributeField(Schema::AttributeField("sp2", schema::INT64)); - s.addAttributeField(Schema::AttributeField("ap2", schema::INT64, schema::ARRAY)); - s.addAttributeField(Schema::AttributeField("wp2", schema::INT64, schema::WEIGHTEDSET)); + s.addAttributeField(Schema::AttributeField("sp2", schema::DataType::INT64)); + s.addAttributeField(Schema::AttributeField("ap2", schema::DataType::INT64, CollectionType::ARRAY)); + s.addAttributeField(Schema::AttributeField("wp2", schema::DataType::INT64, CollectionType::WEIGHTEDSET)); BuildContext bc(s); DBContext dc(bc._repo, getDocTypeName()); @@ -1179,9 +1181,9 @@ void Test::requireThatRawFieldsWorks() { Schema s; - s.addSummaryField(Schema::AttributeField("i", schema::RAW)); - s.addSummaryField(Schema::AttributeField("araw", schema::RAW, schema::ARRAY)); - s.addSummaryField(Schema::AttributeField("wraw", schema::RAW, schema::WEIGHTEDSET)); + s.addSummaryField(Schema::AttributeField("i", schema::DataType::RAW)); + s.addSummaryField(Schema::AttributeField("araw", schema::DataType::RAW, CollectionType::ARRAY)); + s.addSummaryField(Schema::AttributeField("wraw", schema::DataType::RAW, CollectionType::WEIGHTEDSET)); std::vector<char> binaryBlob; binaryBlob.push_back('\0'); @@ -1267,7 +1269,7 @@ void Test::requireThatFieldCacheRepoCanReturnDefaultFieldCache() { Schema s; - s.addSummaryField(Schema::SummaryField("a", schema::INT32)); + s.addSummaryField(Schema::SummaryField("a", schema::DataType::INT32)); BuildContext bc(s); FieldCacheRepo::UP repo = bc.createFieldCacheRepo(getResultConfig()); FieldCache::CSP cache = repo->getFieldCache(""); diff --git a/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp index f3f495925f0..13f0cd1cd2b 100644 --- a/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp +++ b/searchcore/src/tests/proton/docsummary/summaryfieldconverter_test.cpp @@ -50,8 +50,6 @@ #include <vespa/eval/tensor/tensor_factory.h> #include <vespa/vespalib/data/slime/slime.h> -using vespa::config::search::SummarymapConfig; -using vespa::config::search::SummarymapConfigBuilder; using document::Annotation; using document::AnnotationType; using document::ArrayDataType; @@ -59,11 +57,11 @@ using document::ArrayFieldValue; using document::ByteFieldValue; using document::DataType; using document::Document; -using document::DocumenttypesConfig; -using document::DocumenttypesConfigBuilder; using document::DocumentId; using document::DocumentType; using document::DocumentTypeRepo; +using document::DocumenttypesConfig; +using document::DocumenttypesConfigBuilder; using document::DoubleFieldValue; using document::FeatureSet; using document::Field; @@ -75,6 +73,8 @@ using document::LongFieldValue; using document::Predicate; using document::PredicateFieldValue; using document::RawFieldValue; +using document::ReferenceDataType; +using document::ReferenceFieldValue; using document::ShortFieldValue; using document::Span; using document::SpanList; @@ -82,24 +82,25 @@ using document::SpanTree; using document::StringFieldValue; using document::StructDataType; using document::StructFieldValue; +using document::TensorFieldValue; using document::UrlDataType; using document::WeightedSetDataType; using document::WeightedSetFieldValue; -using document::TensorFieldValue; -using document::ReferenceDataType; -using document::ReferenceFieldValue; using search::index::Schema; -using vespalib::Slime; -using vespalib::slime::Cursor; -using vespalib::string; using search::linguistics::SPANTREE_NAME; using search::linguistics::TERM; -using namespace search::docsummary; +using vespa::config::search::SummarymapConfig; +using vespa::config::search::SummarymapConfigBuilder; +using vespalib::Slime; using vespalib::geo::ZCurve; +using vespalib::slime::Cursor; +using vespalib::string; using vespalib::tensor::Tensor; using vespalib::tensor::TensorCells; using vespalib::tensor::TensorDimensions; +using namespace search::docsummary; + typedef SummaryFieldConverter SFC; namespace { @@ -481,11 +482,11 @@ void Test::checkArray(const char *(&str)[N], const FieldValue *value) { } void Test::setSummaryField(const string &field) { - _schema->addSummaryField(Schema::Field(field, search::index::schema::STRING)); + _schema->addSummaryField(Schema::Field(field, search::index::schema::DataType::STRING)); } void Test::setAttributeField(const string &field) { - _schema->addAttributeField(Schema::Field(field, search::index::schema::STRING)); + _schema->addAttributeField(Schema::Field(field, search::index::schema::DataType::STRING)); } void Test::requireThatSummaryIsAnUnmodifiedString() { diff --git a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp index 95c444860b9..66035647d86 100644 --- a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp +++ b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp @@ -15,37 +15,37 @@ #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/testkit/test_kit.h> -using document::DocumentType; -using document::Field; -using namespace proton; - +using document::BucketId; using document::DataType; using document::Document; using document::DocumentId; -using document::BucketId; -using document::IntFieldValue; +using document::DocumentType; using document::DoubleFieldValue; +using document::Field; +using document::IntFieldValue; using document::StringFieldValue; -using search::DocumentIdT; -using search::DocumentMetaData; using search::AttributeContext; using search::AttributeEnumGuard; using search::AttributeGuard; using search::AttributeVector; +using search::DocumentIdT; +using search::DocumentMetaData; using search::attribute::BasicType; using search::attribute::CollectionType; using search::attribute::Config; using search::attribute::IAttributeContext; using search::attribute::test::MockAttributeManager; -using namespace search::index; -using storage::spi::Timestamp; using storage::spi::Bucket; -using storage::spi::PartitionId; -using storage::spi::IterateResult; using storage::spi::DocEntry; -using storage::spi::Selection; using storage::spi::DocumentSelection; using storage::spi::IncludedVersions; +using storage::spi::IterateResult; +using storage::spi::PartitionId; +using storage::spi::Selection; +using storage::spi::Timestamp; + +using namespace proton; +using namespace search::index; const uint64_t largeNum = 10000000; @@ -194,9 +194,9 @@ struct AttrUnitDR : public UnitDR : UnitDR(d->getType(), document::Document::UP(d->clone()), t, b, r), _amgr(), _schema(), _aa(), _dd(), _ss() { - createAttribute(_aa, BasicType::INT32, schema::INT32, "aa"); - createAttribute(_dd, BasicType::DOUBLE, schema::DOUBLE, "dd"); - createAttribute(_ss, BasicType::STRING, schema::STRING, "ss"); + createAttribute(_aa, BasicType::INT32, schema::DataType::INT32, "aa"); + createAttribute(_dd, BasicType::DOUBLE, schema::DataType::DOUBLE, "dd"); + createAttribute(_ss, BasicType::STRING, schema::DataType::STRING, "ss"); } AttrUnitDR(document::Document::UP d, Timestamp t, Bucket b, bool r, @@ -204,11 +204,11 @@ struct AttrUnitDR : public UnitDR : UnitDR(d->getType(), document::Document::UP(d->clone()), t, b, r), _amgr(), _schema(), _aa(), _dd(), _ss() { - createAttribute(_aa, BasicType::INT32, schema::INT32, "aa"); + createAttribute(_aa, BasicType::INT32, schema::DataType::INT32, "aa"); addAttribute<IntFieldValue, int32_t>(*_aa, aa); - createAttribute(_dd, BasicType::DOUBLE, schema::DOUBLE, "dd"); + createAttribute(_dd, BasicType::DOUBLE, schema::DataType::DOUBLE, "dd"); addAttribute<DoubleFieldValue, double>(*_dd, dd); - createAttribute(_ss, BasicType::STRING, schema::STRING, "ss"); + createAttribute(_ss, BasicType::STRING, schema::DataType::STRING, "ss"); addAttribute<StringFieldValue, vespalib::string>(*_ss, ss); } diff --git a/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp b/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp index 6ca02a7a4c5..7fcdf4981bd 100644 --- a/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp @@ -5,6 +5,11 @@ using namespace proton; using namespace search::index; + +using proton::configvalidator::Result; +using proton::configvalidator::ResultType; +using search::index::schema::CollectionType; +using search::index::schema::DataType; using vespa::config::search::AttributesConfig; using vespa::config::search::AttributesConfigBuilder; @@ -12,9 +17,6 @@ typedef Schema::AttributeField AField; typedef Schema::IndexField IField; typedef Schema::SummaryField SField; -using proton::configvalidator::ResultType; -using proton::configvalidator::Result; - const ResultType OK = ResultType::OK; const ResultType DTC = ResultType::DATA_TYPE_CHANGED; const ResultType CTC = ResultType::COLLECTION_TYPE_CHANGED; @@ -47,7 +49,7 @@ struct SchemaBuilder Schema _schema; SchemaBuilder() : _schema() {} SchemaBuilder &add(const vespalib::string &name, FType ftype, - schema::DataType dtype, schema::CollectionType ctype = schema::SINGLE) { + schema::DataType dtype, schema::CollectionType ctype = schema::CollectionType::SINGLE) { switch (ftype) { case INDEX: _schema.addIndexField(IField(name, dtype, ctype)); @@ -74,13 +76,13 @@ create(FType ftype, Schema::DataType dtype, Schema::CollectionType ctype) Schema created(FType ftype, schema::DataType dtype) { - return create(ftype, dtype, schema::SINGLE); + return create(ftype, dtype, CollectionType::SINGLE); } Schema createc(FType ftype, schema::CollectionType ctype) { - return create(ftype, schema::STRING, ctype); + return create(ftype, DataType::STRING, ctype); } ResultType @@ -104,13 +106,13 @@ void requireThatChangedDataTypeIsDiscovered(FType ftype) { EXPECT_EQUAL(DTC, - checkSchema(created(ftype, schema::INT32), - created(ftype, schema::STRING), + checkSchema(created(ftype, DataType::INT32), + created(ftype, DataType::STRING), Schema())); EXPECT_EQUAL(DTC, - checkSchema(created(ftype, schema::INT32), + checkSchema(created(ftype, DataType::INT32), Schema(), - created(ftype, schema::STRING))); + created(ftype, DataType::STRING))); } TEST("require that changed data type is discovered") @@ -124,13 +126,13 @@ void requireThatChangedCollectionTypeIsDiscovered(FType ftype) { EXPECT_EQUAL(CTC, - checkSchema(createc(ftype, schema::ARRAY), - createc(ftype, schema::SINGLE), + checkSchema(createc(ftype, CollectionType::ARRAY), + createc(ftype, CollectionType::SINGLE), Schema())); EXPECT_EQUAL(CTC, - checkSchema(createc(ftype, schema::ARRAY), + checkSchema(createc(ftype, CollectionType::ARRAY), Schema(), - createc(ftype, schema::SINGLE))); + createc(ftype, CollectionType::SINGLE))); } TEST("require that changed collection type is discovered") @@ -142,15 +144,15 @@ TEST("require that changed collection type is discovered") TEST("require that changed index aspect is discovered") { - Schema s1 = created(SUMMARY, schema::STRING); - s1.addIndexField(IField("f1", schema::STRING)); - Schema s2 = created(SUMMARY, schema::STRING); - Schema s2h = created(INDEX, schema::STRING); - - Schema s3 = created(ATTRIBUTE, schema::STRING); - s3.addIndexField(IField("f1", schema::STRING)); - Schema s4 = created(ATTRIBUTE, schema::STRING); - Schema s4h = created(INDEX, schema::STRING); + Schema s1 = created(SUMMARY, DataType::STRING); + s1.addIndexField(IField("f1", DataType::STRING)); + Schema s2 = created(SUMMARY, DataType::STRING); + Schema s2h = created(INDEX, DataType::STRING); + + Schema s3 = created(ATTRIBUTE, DataType::STRING); + s3.addIndexField(IField("f1", DataType::STRING)); + Schema s4 = created(ATTRIBUTE, DataType::STRING); + Schema s4h = created(INDEX, DataType::STRING); { // remove as index field EXPECT_EQUAL(IAR, checkSchema(s2, s1, Schema())); EXPECT_EQUAL(IAR, checkSchema(s2, Schema(), s1)); @@ -174,21 +176,21 @@ TEST("require that changed index aspect is discovered") TEST("require that changed attribute aspect is discovered") { - Schema s1 = created(SUMMARY, schema::STRING); - s1.addAttributeField(AField("f1", schema::STRING)); - Schema s2 = created(SUMMARY, schema::STRING); - Schema s2h = created(ATTRIBUTE, schema::STRING); - - Schema s3 = created(INDEX, schema::STRING); - s3.addAttributeField(AField("f1", schema::STRING)); - Schema s4 = created(INDEX, schema::STRING); - Schema s4h = created(ATTRIBUTE, schema::STRING); - - Schema s5 = created(INDEX, schema::STRING); - s5.addSummaryField(SField("f1", schema::STRING)); - s5.addAttributeField(AField("f1", schema::STRING)); - Schema s6 = created(INDEX, schema::STRING); - s6.addSummaryField(SField("f1", schema::STRING)); + Schema s1 = created(SUMMARY, DataType::STRING); + s1.addAttributeField(AField("f1", DataType::STRING)); + Schema s2 = created(SUMMARY, DataType::STRING); + Schema s2h = created(ATTRIBUTE, DataType::STRING); + + Schema s3 = created(INDEX, DataType::STRING); + s3.addAttributeField(AField("f1", DataType::STRING)); + Schema s4 = created(INDEX, DataType::STRING); + Schema s4h = created(ATTRIBUTE, DataType::STRING); + + Schema s5 = created(INDEX, DataType::STRING); + s5.addSummaryField(SField("f1", DataType::STRING)); + s5.addAttributeField(AField("f1", DataType::STRING)); + Schema s6 = created(INDEX, DataType::STRING); + s6.addSummaryField(SField("f1", DataType::STRING)); { // remove as attribute field EXPECT_EQUAL(AAR, checkSchema(s2, s1, Schema())); EXPECT_EQUAL(AAR, checkSchema(s2, Schema(), s1)); @@ -214,15 +216,15 @@ TEST("require that changed attribute aspect is discovered") TEST("require that changed summary aspect is allowed") { - Schema s1 = created(INDEX, schema::STRING); - s1.addSummaryField(SField("f1", schema::STRING)); - Schema s2 = created(INDEX, schema::STRING); - Schema s2h = created(SUMMARY, schema::STRING); - - Schema s3 = created(ATTRIBUTE, schema::STRING); - s3.addSummaryField(SField("f1", schema::STRING)); - Schema s4 = created(ATTRIBUTE, schema::STRING); - Schema s4h = created(SUMMARY, schema::STRING); + Schema s1 = created(INDEX, DataType::STRING); + s1.addSummaryField(SField("f1", DataType::STRING)); + Schema s2 = created(INDEX, DataType::STRING); + Schema s2h = created(SUMMARY, DataType::STRING); + + Schema s3 = created(ATTRIBUTE, DataType::STRING); + s3.addSummaryField(SField("f1", DataType::STRING)); + Schema s4 = created(ATTRIBUTE, DataType::STRING); + Schema s4h = created(SUMMARY, DataType::STRING); { // remove as summary field EXPECT_EQUAL(OK, checkSchema(s2, s1, Schema())); EXPECT_EQUAL(IAA, checkSchema(s2, Schema(), s1)); @@ -242,16 +244,16 @@ TEST("require that changed summary aspect is allowed") TEST("require that fields can be added and removed") { Schema e; - Schema s1 = created(INDEX, schema::STRING); - Schema s2 = created(ATTRIBUTE, schema::STRING); - Schema s3 = created(SUMMARY, schema::STRING); - Schema s4 = created(SUMMARY, schema::STRING); - s4.addIndexField(IField("f1", schema::STRING)); - Schema s5 = created(SUMMARY, schema::STRING); - s5.addAttributeField(AField("f1", schema::STRING)); - Schema s6 = created(SUMMARY, schema::STRING); - s6.addIndexField(IField("f1", schema::STRING)); - s6.addAttributeField(AField("f1", schema::STRING)); + Schema s1 = created(INDEX, DataType::STRING); + Schema s2 = created(ATTRIBUTE, DataType::STRING); + Schema s3 = created(SUMMARY, DataType::STRING); + Schema s4 = created(SUMMARY, DataType::STRING); + s4.addIndexField(IField("f1", DataType::STRING)); + Schema s5 = created(SUMMARY, DataType::STRING); + s5.addAttributeField(AField("f1", DataType::STRING)); + Schema s6 = created(SUMMARY, DataType::STRING); + s6.addIndexField(IField("f1", DataType::STRING)); + s6.addAttributeField(AField("f1", DataType::STRING)); { // addition of field EXPECT_EQUAL(OK, checkSchema(s1, e, e)); EXPECT_EQUAL(OK, checkSchema(s2, e, e)); @@ -278,53 +280,53 @@ TEST("require that fields can be added and removed") TEST("require that data type changed precedes collection type changed") { - Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, schema::STRING). - add("f2", FType::INDEX, schema::STRING).schema(); - Schema news = SchemaBuilder().add("f1", FType::SUMMARY, schema::INT32). - add("f2", FType::INDEX, schema::STRING, schema::ARRAY).schema(); + Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING). + add("f2", FType::INDEX, DataType::STRING).schema(); + Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::INT32). + add("f2", FType::INDEX, DataType::STRING, CollectionType::ARRAY).schema(); EXPECT_EQUAL(DTC, checkSchema(news, olds, Schema())); } TEST("require that collection type change precedes index aspect added") { - Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, schema::STRING). - add("f2", FType::SUMMARY, schema::STRING).schema(); - Schema news = SchemaBuilder().add("f1", FType::SUMMARY, schema::STRING, schema::ARRAY). - add("f2", FType::SUMMARY, schema::STRING). - add("f2", FType::INDEX, schema::STRING).schema(); + Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING). + add("f2", FType::SUMMARY, DataType::STRING).schema(); + Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING, CollectionType::ARRAY). + add("f2", FType::SUMMARY, DataType::STRING). + add("f2", FType::INDEX, DataType::STRING).schema(); EXPECT_EQUAL(CTC, checkSchema(news, olds, Schema())); } TEST("require that index aspect added precedes index aspect removed") { - Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, schema::STRING). - add("f2", FType::SUMMARY, schema::STRING). - add("f2", FType::INDEX, schema::STRING).schema(); - Schema news = SchemaBuilder().add("f1", FType::SUMMARY, schema::STRING). - add("f1", FType::INDEX, schema::STRING). - add("f2", FType::SUMMARY, schema::STRING).schema(); + Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING). + add("f2", FType::SUMMARY, DataType::STRING). + add("f2", FType::INDEX, DataType::STRING).schema(); + Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING). + add("f1", FType::INDEX, DataType::STRING). + add("f2", FType::SUMMARY, DataType::STRING).schema(); EXPECT_EQUAL(IAA, checkSchema(news, olds, Schema())); } TEST("require that index aspect removed precedes attribute aspect removed") { - Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, schema::STRING). - add("f1", FType::INDEX, schema::STRING). - add("f2", FType::SUMMARY, schema::STRING). - add("f2", FType::ATTRIBUTE, schema::STRING).schema(); - Schema news = SchemaBuilder().add("f1", FType::SUMMARY, schema::STRING). - add("f2", FType::SUMMARY, schema::STRING).schema(); + Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING). + add("f1", FType::INDEX, DataType::STRING). + add("f2", FType::SUMMARY, DataType::STRING). + add("f2", FType::ATTRIBUTE, DataType::STRING).schema(); + Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING). + add("f2", FType::SUMMARY, DataType::STRING).schema(); EXPECT_EQUAL(IAR, checkSchema(news, olds, Schema())); } TEST("require that attribute aspect removed precedes attribute aspect added") { - Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, schema::STRING). - add("f1", FType::ATTRIBUTE, schema::STRING). - add("f2", FType::SUMMARY, schema::STRING).schema(); - Schema news = SchemaBuilder().add("f1", FType::SUMMARY, schema::STRING). - add("f2", FType::SUMMARY, schema::STRING). - add("f2", FType::ATTRIBUTE, schema::STRING).schema(); + Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING). + add("f1", FType::ATTRIBUTE, DataType::STRING). + add("f2", FType::SUMMARY, DataType::STRING).schema(); + Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING). + add("f2", FType::SUMMARY, DataType::STRING). + add("f2", FType::ATTRIBUTE, DataType::STRING).schema(); EXPECT_EQUAL(AAR, checkSchema(news, olds, Schema())); } diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index a33a5f147f2..e423fa4a4ab 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -36,8 +36,10 @@ using documentapi::DocumentReply; using documentapi::RemoveDocumentReply; using documentapi::UpdateDocumentReply; using mbus::Reply; -using namespace search::index; using search::SerialNum; +using search::index::schema::CollectionType; +using search::index::schema::DataType; +using search::makeLambdaTask; using search::transactionlog::TransLogServer; using storage::spi::PartitionId; using storage::spi::RemoveResult; @@ -49,8 +51,9 @@ using vespalib::ThreadStackExecutor; using vespalib::ThreadStackExecutorBase; using vespalib::makeClosure; using vespalib::makeTask; -using search::makeLambdaTask; + using namespace proton; +using namespace search::index; typedef std::unique_ptr<vespalib::CountDownLatch> CountDownLatchUP; @@ -261,7 +264,7 @@ struct SchemaContext { schema(new Schema()), builder() { - schema->addIndexField(Schema::IndexField("i1", schema::STRING, schema::SINGLE)); + schema->addIndexField(Schema::IndexField("i1", DataType::STRING, CollectionType::SINGLE)); builder.reset(new DocBuilder(*schema)); } DocTypeName getDocType() const { diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index 42ddfa23eb6..ddfd84a27a8 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -35,20 +35,20 @@ LOG_SETUP("feedview_test"); using document::BucketId; -using document::DataType; using document::Document; using document::DocumentId; using document::DocumentUpdate; using documentapi::DocumentProtocol; using documentapi::RemoveDocumentReply; using fastos::TimeStamp; -using namespace proton; using proton::matching::SessionManager; +using proton::test::MockGidToLidChangeHandler; using search::AttributeVector; using search::CacheStats; using search::DocumentMetaData; using search::SearchableStats; -using namespace search::index; +using search::index::schema::CollectionType; +using search::index::schema::DataType; using searchcorespi::IndexSearchable; using storage::spi::BucketChecksum; using storage::spi::BucketInfo; @@ -56,7 +56,9 @@ using storage::spi::PartitionId; using storage::spi::Timestamp; using storage::spi::UpdateResult; using vespalib::eval::ValueType; -using proton::test::MockGidToLidChangeHandler; + +using namespace proton; +using namespace search::index; typedef SearchableFeedView::SerialNum SerialNum; typedef search::DocumentIdT DocumentIdT; @@ -437,11 +439,11 @@ SchemaContext::SchemaContext() : _schema(new Schema()), _builder() { - _schema->addIndexField(Schema::IndexField("i1", schema::STRING, schema::SINGLE)); - _schema->addAttributeField(Schema::AttributeField("a1", schema::STRING, schema::SINGLE)); - _schema->addAttributeField(Schema::AttributeField("a2", schema::BOOLEANTREE, schema::SINGLE)); - _schema->addAttributeField(Schema::AttributeField("a3", schema::TENSOR, schema::SINGLE)); - _schema->addSummaryField(Schema::SummaryField("s1", schema::STRING, schema::SINGLE)); + _schema->addIndexField(Schema::IndexField("i1", DataType::STRING, CollectionType::SINGLE)); + _schema->addAttributeField(Schema::AttributeField("a1", DataType::STRING, CollectionType::SINGLE)); + _schema->addAttributeField(Schema::AttributeField("a2", DataType::BOOLEANTREE, CollectionType::SINGLE)); + _schema->addAttributeField(Schema::AttributeField("a3", DataType::TENSOR, CollectionType::SINGLE)); + _schema->addSummaryField(Schema::SummaryField("s1", DataType::STRING, CollectionType::SINGLE)); _builder.reset(new DocBuilder(*_schema)); } SchemaContext::~SchemaContext() {} diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp index a4f4d729beb..579e33250b3 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -16,6 +16,7 @@ #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/testkit/test_kit.h> +using namespace cloud::config::filedistribution; using namespace config; using namespace document; using namespace proton; @@ -23,7 +24,6 @@ using namespace search::index; using namespace search; using namespace vespa::config::search::core; using namespace vespa::config::search; -using namespace cloud::config::filedistribution; using proton::matching::RankingConstants; typedef DocumentDBConfigHelper DBCM; @@ -45,12 +45,12 @@ Schema::SP getSchema(int step) { Schema::SP schema(new Schema); - schema->addIndexField(Schema::IndexField("foo1", schema::STRING)); + schema->addIndexField(Schema::IndexField("foo1", schema::DataType::STRING)); if (step < 2) { - schema->addIndexField(Schema::IndexField("foo2", schema::STRING)); + schema->addIndexField(Schema::IndexField("foo2", schema::DataType::STRING)); } if (step < 1) { - schema->addIndexField(Schema::IndexField("foo3", schema::STRING)); + schema->addIndexField(Schema::IndexField("foo3", schema::DataType::STRING)); } return schema; } @@ -83,7 +83,7 @@ Schema makeHistorySchema() { Schema hs; - hs.addIndexField(Schema::IndexField("history", schema::STRING)); + hs.addIndexField(Schema::IndexField("history", schema::DataType::STRING)); return hs; } diff --git a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp index 3b863561188..72098a94ad4 100644 --- a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp +++ b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp @@ -96,7 +96,7 @@ const uint32_t field_id = 1; Schema getSchema() { Schema schema; - schema.addIndexField(Schema::IndexField(field_name, search::index::schema::STRING)); + schema.addIndexField(Schema::IndexField(field_name, search::index::schema::DataType::STRING)); return schema; } diff --git a/searchcore/src/tests/proton/index/fusionrunner_test.cpp b/searchcore/src/tests/proton/index/fusionrunner_test.cpp index 5b0420bc922..b29e742371c 100644 --- a/searchcore/src/tests/proton/index/fusionrunner_test.cpp +++ b/searchcore/src/tests/proton/index/fusionrunner_test.cpp @@ -27,7 +27,12 @@ LOG_SETUP("fusionrunner_test"); using document::Document; using document::FieldValue; +using proton::ExecutorThreadingService; using search::FixedSourceSelector; +using search::TuneFileAttributes; +using search::TuneFileIndexManager; +using search::TuneFileIndexing; +using search::TuneFileSearch; using search::diskindex::DiskIndex; using search::diskindex::IndexBuilder; using search::fef::MatchData; @@ -35,26 +40,23 @@ using search::fef::MatchDataLayout; using search::fef::TermFieldHandle; using search::fef::TermFieldMatchData; using search::index::DocBuilder; -using search::index::Schema; using search::index::DummyFileHeaderContext; +using search::index::Schema; +using search::index::schema::DataType; using search::memoryindex::MemoryIndex; using search::query::SimpleStringTerm; using search::queryeval::Blueprint; +using search::queryeval::FakeRequestContext; using search::queryeval::FieldSpec; using search::queryeval::FieldSpecList; using search::queryeval::ISourceSelector; using search::queryeval::SearchIterator; -using search::queryeval::FakeRequestContext; +using searchcorespi::index::FusionRunner; +using searchcorespi::index::FusionSpec; using std::set; using std::string; + using namespace proton; -using search::TuneFileAttributes; -using search::TuneFileIndexing; -using search::TuneFileIndexManager; -using search::TuneFileSearch; -using searchcorespi::index::FusionRunner; -using searchcorespi::index::FusionSpec; -using proton::ExecutorThreadingService; namespace { @@ -125,7 +127,7 @@ const uint32_t disk_id[] = { 1, 2, 21, 42 }; Schema getSchema() { Schema schema; schema.addIndexField( - Schema::IndexField(field_name, search::index::schema::STRING)); + Schema::IndexField(field_name, DataType::STRING)); return schema; } diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp index 9d8f4d8b7f6..791e8c2619c 100644 --- a/searchcore/src/tests/proton/index/indexmanager_test.cpp +++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp @@ -33,29 +33,31 @@ LOG_SETUP("indexmanager_test"); using document::Document; using document::FieldValue; +using search::SequencedTaskExecutor; +using search::SerialNum; +using search::TuneFileAttributes; +using search::TuneFileIndexManager; +using search::TuneFileIndexing; using search::datastore::EntryRef; using search::index::DocBuilder; -using search::index::Schema; using search::index::DummyFileHeaderContext; -using search::memoryindex::Dictionary; +using search::index::Schema; +using search::index::schema::DataType; +using search::makeLambdaTask; using search::memoryindex::CompactDocumentWordsStore; +using search::memoryindex::Dictionary; using search::queryeval::Source; -using search::SequencedTaskExecutor; -using search::SerialNum; using std::set; using std::string; +using vespalib::BlockingThreadStackExecutor; using vespalib::Gate; using vespalib::Monitor; using vespalib::MonitorGuard; +using vespalib::ThreadStackExecutor; + using namespace proton; using namespace searchcorespi; using namespace searchcorespi::index; -using search::TuneFileIndexing; -using search::TuneFileIndexManager; -using search::TuneFileAttributes; -using vespalib::BlockingThreadStackExecutor; -using vespalib::ThreadStackExecutor; -using search::makeLambdaTask; namespace { @@ -78,7 +80,7 @@ const uint32_t docid = 1; Schema getSchema() { Schema schema; - schema.addIndexField(Schema::IndexField(field_name, search::index::schema::STRING)); + schema.addIndexField(Schema::IndexField(field_name, DataType::STRING)); return schema; } diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index a1c6538baa7..d745f0dd7c9 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -47,6 +47,8 @@ using namespace search::index; using namespace search::query; using namespace search::queryeval; using namespace search; + +using search::index::schema::DataType; using storage::spi::Timestamp; void inject_match_phase_limiting(Properties &setup, const vespalib::string &attribute, size_t max_hits, bool descending) @@ -133,12 +135,12 @@ struct MyWorld { void basicSetup(size_t heapSize=10, size_t arraySize=100) { // schema - schema.addIndexField(Schema::IndexField("f1", schema::STRING)); - schema.addIndexField(Schema::IndexField("f2", schema::STRING)); - schema.addIndexField(Schema::IndexField("tensor_field", schema::TENSOR)); - schema.addAttributeField(Schema::AttributeField("a1", schema::INT32)); - schema.addAttributeField(Schema::AttributeField("a2", schema::INT32)); - schema.addAttributeField(Schema::AttributeField("predicate_field", schema::BOOLEANTREE)); + schema.addIndexField(Schema::IndexField("f1", DataType::STRING)); + schema.addIndexField(Schema::IndexField("f2", DataType::STRING)); + schema.addIndexField(Schema::IndexField("tensor_field", DataType::TENSOR)); + schema.addAttributeField(Schema::AttributeField("a1", DataType::INT32)); + schema.addAttributeField(Schema::AttributeField("a2", DataType::INT32)); + schema.addAttributeField(Schema::AttributeField("predicate_field", DataType::BOOLEANTREE)); // config config.add(indexproperties::rank::FirstPhase::NAME, "attribute(a1)"); diff --git a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp index 97310597e14..cd1cb1058c7 100644 --- a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp +++ b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp @@ -24,6 +24,7 @@ using namespace search; using namespace search::index; using search::attribute::Config; using search::attribute::BasicType; +using search::index::schema::DataType; const vespalib::string TEST_DIR = "test_output"; const SerialNum INIT_SERIAL_NUM = 10; @@ -63,18 +64,18 @@ struct MyConfig for (auto attr : attrs) { if (attr == "tensor") { _mgr->addAttribute(attr, test::AttributeUtils::getTensorConfig(), 1); - _schema.addAttributeField(Schema::AttributeField(attr, schema::TENSOR)); + _schema.addAttributeField(Schema::AttributeField(attr, DataType::TENSOR)); } else if (attr == "predicate") { _mgr->addAttribute(attr, test::AttributeUtils::getPredicateConfig(), 1); - _schema.addAttributeField(Schema::AttributeField(attr, schema::BOOLEANTREE)); + _schema.addAttributeField(Schema::AttributeField(attr, DataType::BOOLEANTREE)); } else { _mgr->addAttribute(attr, test::AttributeUtils::getStringConfig(), 1); - _schema.addAttributeField(Schema::AttributeField(attr, schema::STRING)); + _schema.addAttributeField(Schema::AttributeField(attr, DataType::STRING)); } } } void addIndexField(const vespalib::string &name) { - _schema.addIndexField(Schema::IndexField(name, schema::STRING)); + _schema.addIndexField(Schema::IndexField(name, DataType::STRING)); } }; diff --git a/searchcore/src/tests/proton/server/documentretriever_test.cpp b/searchcore/src/tests/proton/server/documentretriever_test.cpp index 8f94f382870..d3a1f4d47cf 100644 --- a/searchcore/src/tests/proton/server/documentretriever_test.cpp +++ b/searchcore/src/tests/proton/server/documentretriever_test.cpp @@ -38,7 +38,6 @@ using document::ArrayFieldValue; using document::FieldValue; using document::BucketId; -using document::DataType; using document::Document; using document::DocumentId; using document::DocumentType; @@ -68,6 +67,7 @@ using search::attribute::CollectionType; using search::attribute::Config; using search::attribute::IAttributeVector; using search::index::Schema; +using search::index::schema::DataType; using storage::spi::Bucket; using storage::spi::GetResult; using storage::spi::PartitionId; @@ -150,25 +150,25 @@ document::DocumenttypesConfig getRepoConfig() { builder.document(doc_type_id, doc_type_name, Struct(doc_type_name + ".header"), Struct(doc_type_name + ".body") - .addField(static_field, DataType::T_INT) - .addField(dyn_field_i, DataType::T_INT) - .addField(dyn_field_d, DataType::T_DOUBLE) - .addField(dyn_field_s, DataType::T_STRING) - .addField(dyn_field_n, DataType::T_FLOAT) - .addField(dyn_field_nai, DataType::T_INT) - .addField(dyn_field_nas, DataType::T_STRING) - .addField(dyn_field_p, DataType::T_PREDICATE) - .addField(dyn_arr_field_i, Array(DataType::T_INT)) - .addField(dyn_arr_field_d, Array(DataType::T_DOUBLE)) - .addField(dyn_arr_field_s, Array(DataType::T_STRING)) - .addField(dyn_arr_field_n, Array(DataType::T_FLOAT)) - .addField(dyn_wset_field_i, Wset(DataType::T_INT)) - .addField(dyn_wset_field_d, Wset(DataType::T_DOUBLE)) - .addField(dyn_wset_field_s, Wset(DataType::T_STRING)) - .addField(dyn_wset_field_n, Wset(DataType::T_FLOAT)) + .addField(static_field, document::DataType::T_INT) + .addField(dyn_field_i, document::DataType::T_INT) + .addField(dyn_field_d, document::DataType::T_DOUBLE) + .addField(dyn_field_s, document::DataType::T_STRING) + .addField(dyn_field_n, document::DataType::T_FLOAT) + .addField(dyn_field_nai, document::DataType::T_INT) + .addField(dyn_field_nas, document::DataType::T_STRING) + .addField(dyn_field_p, document::DataType::T_PREDICATE) + .addField(dyn_arr_field_i, Array(document::DataType::T_INT)) + .addField(dyn_arr_field_d, Array(document::DataType::T_DOUBLE)) + .addField(dyn_arr_field_s, Array(document::DataType::T_STRING)) + .addField(dyn_arr_field_n, Array(document::DataType::T_FLOAT)) + .addField(dyn_wset_field_i, Wset(document::DataType::T_INT)) + .addField(dyn_wset_field_d, Wset(document::DataType::T_DOUBLE)) + .addField(dyn_wset_field_s, Wset(document::DataType::T_STRING)) + .addField(dyn_wset_field_n, Wset(document::DataType::T_FLOAT)) .addField(position_field, PositionDataType::getInstance().getId()) - .addField(zcurve_field, DataType::T_LONG)); + .addField(zcurve_field, document::DataType::T_LONG)); return builder.config(); } @@ -176,17 +176,17 @@ BasicType convertDataType(Schema::DataType t) { switch (t) { - case schema::INT32: + case DataType::INT32: return BasicType::INT32; - case schema::INT64: + case DataType::INT64: return BasicType::INT64; - case schema::FLOAT: + case DataType::FLOAT: return BasicType::FLOAT; - case schema::DOUBLE: + case DataType::DOUBLE: return BasicType::DOUBLE; - case schema::STRING: + case DataType::STRING: return BasicType::STRING; - case schema::BOOLEANTREE: + case DataType::BOOLEANTREE: return BasicType::PREDICATE; default: throw std::runtime_error(make_string("Data type %u not handled", (uint32_t)t)); @@ -197,11 +197,11 @@ CollectionType convertCollectionType(Schema::CollectionType ct) { switch (ct) { - case schema::SINGLE: + case schema::CollectionType::SINGLE: return CollectionType::SINGLE; - case schema::ARRAY: + case schema::CollectionType::ARRAY: return CollectionType::ARRAY; - case schema::WEIGHTEDSET: + case schema::CollectionType::WEIGHTEDSET: return CollectionType::WSET; default: throw std::runtime_error(make_string("Collection type %u not handled", (uint32_t)ct)); @@ -247,7 +247,7 @@ struct Fixture { void addAttribute(const char *name, U val, Schema::DataType t, Schema::CollectionType ct) { T *attr = addAttribute<T>(name, t, ct); - if (ct == schema::SINGLE) { + if (ct == schema::CollectionType::SINGLE) { attr->update(lid, val); } else { attr->append(lid, val + 1, dyn_weight); @@ -277,43 +277,43 @@ struct Fixture { Result putRes(meta_store.get().put(gid, bucket_id, timestamp, docSize, inspect.getLid())); lid = putRes.getLid(); ASSERT_TRUE(putRes.ok()); - schema::CollectionType ct = schema::SINGLE; + schema::CollectionType ct = schema::CollectionType::SINGLE; addAttribute<IntegerAttribute>( - dyn_field_i, dyn_value_i, schema::INT32, ct); + dyn_field_i, dyn_value_i, DataType::INT32, ct); addAttribute<FloatingPointAttribute>( - dyn_field_d, dyn_value_d, schema::DOUBLE, ct); + dyn_field_d, dyn_value_d, DataType::DOUBLE, ct); addAttribute<StringAttribute>( - dyn_field_s, dyn_value_s, schema::STRING, ct); + dyn_field_s, dyn_value_s, DataType::STRING, ct); addAttribute<FloatingPointAttribute>( - dyn_field_n, schema::FLOAT, ct); + dyn_field_n, DataType::FLOAT, ct); addAttribute<IntegerAttribute>( - dyn_field_nai, schema::INT32, ct); + dyn_field_nai, DataType::INT32, ct); addAttribute<StringAttribute>( - dyn_field_nas, schema::STRING, ct); + dyn_field_nas, DataType::STRING, ct); addAttribute<IntegerAttribute>( - zcurve_field, dynamic_zcurve_value, schema::INT64, ct); + zcurve_field, dynamic_zcurve_value, DataType::INT64, ct); PredicateAttribute *attr = addAttribute<PredicateAttribute>( - dyn_field_p, schema::BOOLEANTREE, ct); + dyn_field_p, DataType::BOOLEANTREE, ct); attr->getIndex().indexEmptyDocument(lid); attr->commit(); - ct = schema::ARRAY; + ct = schema::CollectionType::ARRAY; addAttribute<IntegerAttribute>( - dyn_arr_field_i, dyn_value_i, schema::INT32, ct); + dyn_arr_field_i, dyn_value_i, DataType::INT32, ct); addAttribute<FloatingPointAttribute>( - dyn_arr_field_d, dyn_value_d, schema::DOUBLE, ct); + dyn_arr_field_d, dyn_value_d, DataType::DOUBLE, ct); addAttribute<StringAttribute>( - dyn_arr_field_s, dyn_value_s, schema::STRING, ct); + dyn_arr_field_s, dyn_value_s, DataType::STRING, ct); addAttribute<FloatingPointAttribute>( - dyn_arr_field_n, schema::FLOAT, ct); - ct = schema::WEIGHTEDSET; + dyn_arr_field_n, DataType::FLOAT, ct); + ct = schema::CollectionType::WEIGHTEDSET; addAttribute<IntegerAttribute>( - dyn_wset_field_i, dyn_value_i, schema::INT32, ct); + dyn_wset_field_i, dyn_value_i, DataType::INT32, ct); addAttribute<FloatingPointAttribute>( - dyn_wset_field_d, dyn_value_d, schema::DOUBLE, ct); + dyn_wset_field_d, dyn_value_d, DataType::DOUBLE, ct); addAttribute<StringAttribute>( - dyn_wset_field_s, dyn_value_s, schema::STRING, ct); + dyn_wset_field_s, dyn_value_s, DataType::STRING, ct); addAttribute<FloatingPointAttribute>( - dyn_wset_field_n, schema::FLOAT, ct); + dyn_wset_field_n, DataType::FLOAT, ct); } }; @@ -407,7 +407,7 @@ TEST_F("require that attributes are patched into stored document", Fixture) { } TEST_F("require that attributes are patched into stored document unless also index field", Fixture) { - f.schema.addIndexField(Schema::IndexField(dyn_field_s, schema::STRING)); + f.schema.addIndexField(Schema::IndexField(dyn_field_s, DataType::STRING)); DocumentMetaData meta_data = f.retriever.getDocumentMetaData(doc_id); Document::UP doc = f.retriever.getDocument(meta_data.lid); ASSERT_TRUE(doc.get()); diff --git a/searchcore/src/tests/proton/server/memoryconfigstore_test.cpp b/searchcore/src/tests/proton/server/memoryconfigstore_test.cpp index 387fff27ca9..8b21ed40fc8 100644 --- a/searchcore/src/tests/proton/server/memoryconfigstore_test.cpp +++ b/searchcore/src/tests/proton/server/memoryconfigstore_test.cpp @@ -11,8 +11,10 @@ LOG_SETUP("memoryconfigstore_test"); #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchcore/proton/common/schemautil.h> -using search::index::Schema; using search::SerialNum; +using search::index::Schema; +using search::index::schema::DataType; + using namespace proton; namespace { @@ -35,12 +37,12 @@ Schema::SP getSchema(int step) { Schema::SP schema(new Schema); - schema->addIndexField(Schema::IndexField("foo1", search::index::schema::STRING)); + schema->addIndexField(Schema::IndexField("foo1", DataType::STRING)); if (step < 2) { - schema->addIndexField(Schema::IndexField("foo2", search::index::schema::STRING)); + schema->addIndexField(Schema::IndexField("foo2", DataType::STRING)); } if (step < 1) { - schema->addIndexField(Schema::IndexField("foo3", search::index::schema::STRING)); + schema->addIndexField(Schema::IndexField("foo3", DataType::STRING)); } return schema; } @@ -113,7 +115,7 @@ TEST("require that wipe history clears previous history schema " "and adds new, identical entry for current serial num") { MemoryConfigStore config_store; Schema::SP history(new Schema); - history->addIndexField(Schema::IndexField("foo", search::index::schema::STRING)); + history->addIndexField(Schema::IndexField("foo", DataType::STRING)); config_store.saveConfig(*getConfig(10), *history, 5); DocumentDBConfig::SP config; config_store.loadConfig(*getConfig(14), 5, config, history); @@ -171,7 +173,7 @@ TEST("require that wipe history clears only portions of history") TEST("require that wipe history does nothing if serial num exists") { MemoryConfigStore config_store; Schema::SP history(new Schema); - history->addIndexField(Schema::IndexField("foo", search::index::schema::STRING)); + history->addIndexField(Schema::IndexField("foo", DataType::STRING)); config_store.saveConfig(*getConfig(10), *history, 5); DocumentDBConfig::SP config; config_store.saveWipeHistoryConfig(5, 0); diff --git a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp index fcbf4e3c241..2c5e119ecbe 100644 --- a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp +++ b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp @@ -18,6 +18,9 @@ const char *invalid_feature = "invalid_feature_name and format"; using namespace search::fef::indexproperties; using namespace search::index; +using search::index::schema::CollectionType; +using search::index::schema::DataType; + struct Writer { FILE *file; Writer(const std::string &file_name) { @@ -185,10 +188,10 @@ struct EmptyModel : Model {}; struct SimpleModel : Model { SimpleModel() : Model() { - index("title", schema::STRING, schema::SINGLE); - index("list", schema::STRING, schema::ARRAY); - index("keywords", schema::STRING, schema::WEIGHTEDSET); - attribute("date", schema::INT32, schema::SINGLE); + index("title", DataType::STRING, CollectionType::SINGLE); + index("list", DataType::STRING, CollectionType::ARRAY); + index("keywords", DataType::STRING, CollectionType::WEIGHTEDSET); + attribute("date", DataType::INT32, CollectionType::SINGLE); imported_attribute("imported_attr"); constants["my_tensor"] = "tensor(x{},y{})"; } @@ -196,8 +199,8 @@ struct SimpleModel : Model { struct ShadowModel : Model { ShadowModel() : Model() { - index("both", schema::STRING, schema::SINGLE); - attribute("both", schema::STRING, schema::SINGLE); + index("both", DataType::STRING, CollectionType::SINGLE); + attribute("both", DataType::STRING, CollectionType::SINGLE); } }; diff --git a/searchcore/src/vespa/searchcore/proton/attribute/document_field_retriever.cpp b/searchcore/src/vespa/searchcore/proton/attribute/document_field_retriever.cpp index d63bb60dbae..dbe23f16e57 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/document_field_retriever.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/document_field_retriever.cpp @@ -12,19 +12,21 @@ #include <vespa/log/log.h> LOG_SETUP(".proton.attribute.document_field_retriever"); -using search::DocumentIdT; using document::ArrayFieldValue; using document::Document; using document::Field; using document::FieldValue; using document::TensorFieldValue; using document::WeightedSetFieldValue; -using namespace search::index; +using search::DocumentIdT; using search::attribute::AttributeContent; using search::attribute::IAttributeVector; using search::attribute::WeightedType; +using search::index::schema::CollectionType; +using search::index::schema::DataType; using search::tensor::TensorAttribute; using vespalib::IllegalStateException; +using namespace search::index; namespace proton { @@ -38,7 +40,7 @@ setValue(DocumentIdT lid, const IAttributeVector &attr) { switch (field.getCollectionType()) { - case schema::SINGLE: + case CollectionType::SINGLE: { if ( ! attr.isUndefined(lid) ) { AttributeContent<T> content; @@ -49,7 +51,7 @@ setValue(DocumentIdT lid, } break; } - case schema::ARRAY: + case CollectionType::ARRAY: { AttributeContent<T> content; content.fill(attr, lid); @@ -69,7 +71,7 @@ setValue(DocumentIdT lid, doc.setValue(f, *fv); break; } - case schema::WEIGHTEDSET: + case CollectionType::WEIGHTEDSET: { AttributeContent<WeightedType<T> > content; content.fill(attr, lid); @@ -107,34 +109,34 @@ DocumentFieldRetriever::populate(DocumentIdT lid, bool isIndexField) { switch (field.getDataType()) { - case schema::UINT1: - case schema::UINT2: - case schema::UINT4: - case schema::INT8: - case schema::INT16: - case schema::INT32: - case schema::INT64: + case DataType::UINT1: + case DataType::UINT2: + case DataType::UINT4: + case DataType::INT8: + case DataType::INT16: + case DataType::INT32: + case DataType::INT64: setValue<IAttributeVector::largeint_t>( lid, doc, field, attr); break; - case schema::FLOAT: - case schema::DOUBLE: + case DataType::FLOAT: + case DataType::DOUBLE: setValue<double>(lid, doc, field, attr); break; - case schema::STRING: + case DataType::STRING: // If it is a stringfield we also need to check if // it is an index field. In that case we shall // keep the original in order to preserve annotations. if (isIndexField) { break; } - case schema::RAW: + case DataType::RAW: setValue<const char *>(lid, doc, field, attr); break; - case schema::BOOLEANTREE: + case DataType::BOOLEANTREE: // Predicate attribute doesn't store documents, it only indexes them. break; - case schema::TENSOR: + case DataType::TENSOR: // Tensor attribute is not authorative. Partial updates must update // document store. break; diff --git a/searchcore/src/vespa/searchcore/proton/reprocessing/attribute_reprocessing_initializer.cpp b/searchcore/src/vespa/searchcore/proton/reprocessing/attribute_reprocessing_initializer.cpp index 33b27f947c7..23848c49772 100644 --- a/searchcore/src/vespa/searchcore/proton/reprocessing/attribute_reprocessing_initializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/reprocessing/attribute_reprocessing_initializer.cpp @@ -13,6 +13,7 @@ using namespace search::index; using search::AttributeGuard; using search::AttributeVector; using search::SerialNum; +using search::index::schema::DataType; namespace proton { @@ -30,7 +31,7 @@ toStr(bool value) bool fastPartialUpdateAttribute(const schema::DataType &attrType) { // Partial update to tensor or predicate attribute must update document - return ((attrType != schema::BOOLEANTREE) && (attrType != schema::TENSOR) && (attrType != schema::DataType::REFERENCE)); + return ((attrType != DataType::BOOLEANTREE) && (attrType != DataType::TENSOR) && (attrType != DataType::REFERENCE)); } @@ -101,7 +102,7 @@ getFieldsToPopulate(const ARIConfig &newCfg, bool unchangedField = inspector.hasUnchangedField(name); // NOTE: If it is a string and index field we shall // keep the original in order to preserve annotations. - bool isStringIndexField = attrField.getDataType() == schema::STRING && + bool isStringIndexField = attrField.getDataType() == DataType::STRING && newCfg.getSchema().isIndexField(name); bool populateField = !inNewAttrMgr && unchangedField && !isStringIndexField && fastPartialUpdateAttribute(attrType); 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()); diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.cpp b/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.cpp index b02e1944368..55723eec558 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.cpp +++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.cpp @@ -20,6 +20,10 @@ SimpleMemoryLogic::SimpleMemoryLogic(Clock& c, uint64_t maxMemory) LOG(debug, "Setup simple memory logic with max memory of %" PRIu64 " bytes", maxMemory); } +SimpleMemoryLogic::~SimpleMemoryLogic() +{ +} + void SimpleMemoryLogic::setMaximumMemoryUsage(uint64_t max) { diff --git a/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.h b/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.h index 5a8df6441f1..8cbb8d13111 100644 --- a/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.h +++ b/storageframework/src/vespa/storageframework/defaultimplementation/memory/simplememorylogic.h @@ -59,6 +59,8 @@ public: SimpleMemoryLogic(Clock&, uint64_t maxMemory); + ~SimpleMemoryLogic(); + SimpleMemoryLogic& setMinJumpToUpdateMax(uint32_t bytes) { _state.setMinJumpToUpdateMax(bytes); return *this; |