diff options
14 files changed, 40 insertions, 205 deletions
diff --git a/searchsummary/src/tests/docsummary/document_id_dfw/document_id_dfw_test.cpp b/searchsummary/src/tests/docsummary/document_id_dfw/document_id_dfw_test.cpp index 4819c34272c..5e49e9e714e 100644 --- a/searchsummary/src/tests/docsummary/document_id_dfw/document_id_dfw_test.cpp +++ b/searchsummary/src/tests/docsummary/document_id_dfw/document_id_dfw_test.cpp @@ -85,7 +85,7 @@ DocumentIdDFWTest::DocumentIdDFWTest() _document_type(_repo->getDocumentType(doc_type_name)) { auto* cfg = _result_config->AddResultClass("default", 0); - cfg->AddConfigEntry(_field_name.c_str(), search::docsummary::RES_LONG_STRING); + cfg->AddConfigEntry(_field_name.c_str()); } diff --git a/searchsummary/src/tests/docsummary/matched_elements_filter/matched_elements_filter_test.cpp b/searchsummary/src/tests/docsummary/matched_elements_filter/matched_elements_filter_test.cpp index 8ac37ae76eb..f0dd4acfb32 100644 --- a/searchsummary/src/tests/docsummary/matched_elements_filter/matched_elements_filter_test.cpp +++ b/searchsummary/src/tests/docsummary/matched_elements_filter/matched_elements_filter_test.cpp @@ -97,13 +97,11 @@ public: _doc_type.addField(Field("wset", _wset_type)); auto* result_class = _config.AddResultClass("test", class_id); - EXPECT_TRUE(result_class->AddConfigEntry("array", ResType::RES_JSONSTRING)); - EXPECT_TRUE(result_class->AddConfigEntry("map", ResType::RES_JSONSTRING)); - EXPECT_TRUE(result_class->AddConfigEntry("map2", ResType::RES_JSONSTRING)); + EXPECT_TRUE(result_class->AddConfigEntry("array")); + EXPECT_TRUE(result_class->AddConfigEntry("map")); + EXPECT_TRUE(result_class->AddConfigEntry("map2")); } ~DocsumStore(); - const ResultConfig& get_config() const { return _config; } - const ResultClass* get_class() const { return _config.LookupResultClass(class_id); } std::unique_ptr<IDocsumStoreDocument> getMappedDocsum() { auto doc = std::make_unique<Document>(_doc_type, DocumentId("id:test:test::0")); { diff --git a/searchsummary/src/tests/docsummary/slime_summary/slime_summary_test.cpp b/searchsummary/src/tests/docsummary/slime_summary/slime_summary_test.cpp index fa53cf202ff..7b3e79ec38e 100644 --- a/searchsummary/src/tests/docsummary/slime_summary/slime_summary_test.cpp +++ b/searchsummary/src/tests/docsummary/slime_summary/slime_summary_test.cpp @@ -106,17 +106,17 @@ SlimeSummaryTest::SlimeSummaryTest() auto config = std::make_unique<ResultConfig>(); ResultClass *cfg = config->AddResultClass("default", 0); EXPECT_TRUE(cfg != nullptr); - EXPECT_TRUE(cfg->AddConfigEntry("int_field", RES_INT)); - EXPECT_TRUE(cfg->AddConfigEntry("short_field", RES_SHORT)); - EXPECT_TRUE(cfg->AddConfigEntry("byte_field", RES_BYTE)); - EXPECT_TRUE(cfg->AddConfigEntry("float_field", RES_FLOAT)); - EXPECT_TRUE(cfg->AddConfigEntry("double_field", RES_DOUBLE)); - EXPECT_TRUE(cfg->AddConfigEntry("int64_field", RES_INT64)); - EXPECT_TRUE(cfg->AddConfigEntry("string_field", RES_STRING)); - EXPECT_TRUE(cfg->AddConfigEntry("data_field", RES_DATA)); - EXPECT_TRUE(cfg->AddConfigEntry("longstring_field", RES_LONG_STRING)); - EXPECT_TRUE(cfg->AddConfigEntry("longdata_field", RES_LONG_DATA)); - EXPECT_TRUE(cfg->AddConfigEntry("int_pair_field", RES_JSONSTRING)); + EXPECT_TRUE(cfg->AddConfigEntry("int_field")); + EXPECT_TRUE(cfg->AddConfigEntry("short_field")); + EXPECT_TRUE(cfg->AddConfigEntry("byte_field")); + EXPECT_TRUE(cfg->AddConfigEntry("float_field")); + EXPECT_TRUE(cfg->AddConfigEntry("double_field")); + EXPECT_TRUE(cfg->AddConfigEntry("int64_field")); + EXPECT_TRUE(cfg->AddConfigEntry("string_field")); + EXPECT_TRUE(cfg->AddConfigEntry("data_field")); + EXPECT_TRUE(cfg->AddConfigEntry("longstring_field")); + EXPECT_TRUE(cfg->AddConfigEntry("longdata_field")); + EXPECT_TRUE(cfg->AddConfigEntry("int_pair_field")); config->set_default_result_class_id(0); writer = std::make_unique<DynamicDocsumWriter>(std::move(config), std::unique_ptr<KeywordExtractor>()); int_pair_type.addField(Field("foo", *DataType::INT)); diff --git a/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt b/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt index 37ee0697149..51c8afe4250 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt +++ b/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt @@ -29,7 +29,6 @@ vespa_add_library(searchsummary_docsummary OBJECT positionsdfw.cpp rankfeaturesdfw.cpp res_config_entry.cpp - res_type_utils.cpp resultclass.cpp resultconfig.cpp searchdatatype.cpp diff --git a/searchsummary/src/vespa/searchsummary/docsummary/res_config_entry.cpp b/searchsummary/src/vespa/searchsummary/docsummary/res_config_entry.cpp index 0bf9e61fc36..12e87cbd899 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/res_config_entry.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/res_config_entry.cpp @@ -6,8 +6,7 @@ namespace search::docsummary { ResConfigEntry::ResConfigEntry() noexcept - : _type(RES_BAD), - _name(), + : _name(), _docsum_field_writer() { } diff --git a/searchsummary/src/vespa/searchsummary/docsummary/res_config_entry.h b/searchsummary/src/vespa/searchsummary/docsummary/res_config_entry.h index b5b5c620c88..02090df8229 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/res_config_entry.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/res_config_entry.h @@ -2,7 +2,6 @@ #pragma once -#include "res_type.h" #include <vespa/vespalib/stllike/string.h> #include <memory> @@ -14,7 +13,6 @@ class DocsumFieldWriter; * This struct describes a single docsum field (name and type). **/ struct ResConfigEntry { - ResType _type; vespalib::string _name; std::unique_ptr<DocsumFieldWriter> _docsum_field_writer; ResConfigEntry() noexcept; diff --git a/searchsummary/src/vespa/searchsummary/docsummary/res_type.h b/searchsummary/src/vespa/searchsummary/docsummary/res_type.h deleted file mode 100644 index e86e0eeedc8..00000000000 --- a/searchsummary/src/vespa/searchsummary/docsummary/res_type.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -namespace search::docsummary { - -/** - * This enumeration contains values denoting the different types of - * docsum fields. NOTE: The internal implementation depends on RES_INT - * having the value 0. All types < RES_STRING must be fixed size and - * all types > RES_STRING must be variable size. - **/ -enum ResType { - RES_INT = 0, - RES_SHORT, - RES_BOOL, - RES_BYTE, - RES_FLOAT, - RES_DOUBLE, - RES_INT64, - RES_STRING, - RES_DATA, - RES_LONG_STRING, - RES_LONG_DATA, - RES_JSONSTRING, - RES_TENSOR, - RES_FEATUREDATA, - RES_BAD -}; - -} diff --git a/searchsummary/src/vespa/searchsummary/docsummary/res_type_utils.cpp b/searchsummary/src/vespa/searchsummary/docsummary/res_type_utils.cpp deleted file mode 100644 index f7a1aae7455..00000000000 --- a/searchsummary/src/vespa/searchsummary/docsummary/res_type_utils.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "res_type_utils.h" - -namespace search::docsummary { - -const char * -ResTypeUtils::GetResTypeName(ResType type) -{ - switch (type) { - case RES_INT: return "integer"; - case RES_SHORT: return "short"; - case RES_BYTE: return "byte"; - case RES_BOOL: return "bool"; - case RES_FLOAT: return "float"; - case RES_DOUBLE: return "double"; - case RES_INT64: return "int64"; - case RES_STRING: return "string"; - case RES_DATA: return "data"; - case RES_LONG_STRING: return "longstring"; - case RES_LONG_DATA: return "longdata"; - case RES_JSONSTRING: return "jsonstring"; - case RES_TENSOR: return "tensor"; - case RES_FEATUREDATA: return "featuredata"; - default: return "unknown-type"; - } -} - -ResType -ResTypeUtils::get_res_type(vespalib::stringref name) -{ - if (name == "integer") { - return RES_INT; - } - if (name == "short") { - return RES_SHORT; - } - if (name == "byte") { - return RES_BYTE; - } - if (name == "bool") { - return RES_BOOL; - } - if (name == "float") { - return RES_FLOAT; - } - if (name == "double") { - return RES_DOUBLE; - } - if (name == "int64") { - return RES_INT64; - } - if (name == "string") { - return RES_STRING; - } - if (name == "data") { - return RES_DATA; - } - if (name == "longstring") { - return RES_LONG_STRING; - } - if (name == "longdata") { - return RES_LONG_DATA; - } - if (name == "jsonstring") { - return RES_JSONSTRING; - } - if (name == "tensor") { - return RES_TENSOR; - } - if (name == "featuredata") { - return RES_FEATUREDATA; - } - // Known aliases - if (name == "raw") { - return RES_DATA; - } - if (name == "xmlstring") { - return RES_JSONSTRING; - } - return RES_BAD; -} - -} diff --git a/searchsummary/src/vespa/searchsummary/docsummary/res_type_utils.h b/searchsummary/src/vespa/searchsummary/docsummary/res_type_utils.h deleted file mode 100644 index a2e881b5b4d..00000000000 --- a/searchsummary/src/vespa/searchsummary/docsummary/res_type_utils.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include "res_type.h" -#include <vespa/vespalib/stllike/string.h> - -namespace search::docsummary { - -/* - * Utilitiy functions for checking if result type is ok. - */ -struct ResTypeUtils -{ - /** - * @return the name of the given result field type. - * @param resType enum value of a result field type. - **/ - static const char *GetResTypeName(ResType type); - - static ResType get_res_type(vespalib::stringref name); -}; - -} diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp index d19a111080f..e6eb3064176 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp @@ -2,9 +2,7 @@ #include "resultclass.h" #include "docsum_field_writer.h" -#include "resultconfig.h" #include <vespa/vespalib/stllike/hashtable.hpp> -#include <cassert> namespace search::docsummary { @@ -28,7 +26,7 @@ ResultClass::GetIndexFromName(const char* name) const } bool -ResultClass::AddConfigEntry(const char *name, ResType type, std::unique_ptr<DocsumFieldWriter> docsum_field_writer) +ResultClass::AddConfigEntry(const char *name, std::unique_ptr<DocsumFieldWriter> docsum_field_writer) { if (_nameMap.find(name) != _nameMap.end()) { return false; @@ -36,7 +34,6 @@ ResultClass::AddConfigEntry(const char *name, ResType type, std::unique_ptr<Docs _nameMap[name] = _entries.size(); ResConfigEntry e; - e._type = type; e._name = name; if (docsum_field_writer) { docsum_field_writer->setIndex(_entries.size()); @@ -52,9 +49,9 @@ ResultClass::AddConfigEntry(const char *name, ResType type, std::unique_ptr<Docs } bool -ResultClass::AddConfigEntry(const char *name, ResType type) +ResultClass::AddConfigEntry(const char *name) { - return AddConfigEntry(name, type, {}); + return AddConfigEntry(name, {}); } } diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h index 7b4168a3ed9..19f39eeb1f1 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h @@ -91,11 +91,10 @@ public: * * @return true(success)/false(fail) * @param name the name of the field to add. - * @param type the type of the field to add. * @param docsum_field_writer field writer for writing field **/ - bool AddConfigEntry(const char *name, ResType type, std::unique_ptr<DocsumFieldWriter> docsum_field_writer); - bool AddConfigEntry(const char *name, ResType type); + bool AddConfigEntry(const char *name, std::unique_ptr<DocsumFieldWriter> docsum_field_writer); + bool AddConfigEntry(const char *name); /** * Obtain the field index from the field name. The field index may diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp index 4f5b5db841c..8a70b5b7782 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp @@ -124,34 +124,26 @@ ResultConfig::ReadConfig(const SummaryConfig &cfg, const char *configId, IDocsum break; } resClass->set_omit_summary_features(cfg_class.omitsummaryfeatures); - for (unsigned int j = 0; rc && (j < cfg_class.fields.size()); j++) { - const char *fieldtype = cfg_class.fields[j].type.c_str(); - const char *fieldname = cfg_class.fields[j].name.c_str(); - vespalib::string command = cfg_class.fields[j].command; - vespalib::string source_name = cfg_class.fields[j].source; - auto res_type = ResTypeUtils::get_res_type(fieldtype); - LOG(debug, "Reconfiguring class '%s' field '%s' of type '%s'", cfg_class.name.c_str(), fieldname, fieldtype); - if (res_type != RES_BAD) { - std::unique_ptr<DocsumFieldWriter> docsum_field_writer; - if (!command.empty()) { - try { - docsum_field_writer = docsum_field_writer_factory.create_docsum_field_writer(fieldname, - command, - source_name); - } catch (const vespalib::IllegalArgumentException& ex) { - LOG(error, "Exception during setup of summary result class '%s': field='%s', command='%s', source='%s': %s", - cfg_class.name.c_str(), fieldname, command.c_str(), source_name.c_str(), ex.getMessage().c_str()); - break; - } + for (const auto & field : cfg_class.fields) { + const char *fieldname = field.name.c_str(); + vespalib::string command = field.command; + vespalib::string source_name = field.source; + LOG(debug, "Reconfiguring class '%s' field '%s'", cfg_class.name.c_str(), fieldname); + std::unique_ptr<DocsumFieldWriter> docsum_field_writer; + if (!command.empty()) { + try { + docsum_field_writer = docsum_field_writer_factory.create_docsum_field_writer(fieldname, + command, + source_name); + } catch (const vespalib::IllegalArgumentException& ex) { + LOG(error, "Exception during setup of summary result class '%s': field='%s', command='%s', source='%s': %s", + cfg_class.name.c_str(), fieldname, command.c_str(), source_name.c_str(), ex.getMessage().c_str()); + break; } - rc = resClass->AddConfigEntry(fieldname, res_type, std::move(docsum_field_writer)); - } else { - LOG(error, "%s %s.fields[%d]: unknown type '%s'", configId, cfg_class.name.c_str(), j, fieldtype); - rc = false; - break; } + rc = resClass->AddConfigEntry(fieldname, std::move(docsum_field_writer)); if (!rc) { - LOG(error, "%s %s.fields[%d]: duplicate name '%s'", configId, cfg_class.name.c_str(), j, fieldname); + LOG(error, "%s %s.fields: duplicate name '%s'", configId, cfg_class.name.c_str(), fieldname); break; } } diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h index 0e9f720cbad..c690d40f8c2 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h @@ -2,7 +2,6 @@ #pragma once -#include "res_type_utils.h" #include <vespa/vespalib/stllike/hash_map.h> namespace vespa::config::search::internal { @@ -98,12 +97,6 @@ public: static void set_wanted_v8_geo_positions(bool value); /** - * @return the name of the given result field type. - * @param resType enum value of a result field type. - **/ - static const char *GetResTypeName(ResType type) { return ResTypeUtils::GetResTypeName(type); } - - /** * Discard the current configuration and start over. After this * method returns, the state of this object will be equal to the * state right after it was created. This method may call both Clean diff --git a/streamingvisitors/src/vespa/vsm/vsm/docsumfilter.h b/streamingvisitors/src/vespa/vsm/vsm/docsumfilter.h index 9ec6cb54f51..339627be9ea 100644 --- a/streamingvisitors/src/vespa/vsm/vsm/docsumfilter.h +++ b/streamingvisitors/src/vespa/vsm/vsm/docsumfilter.h @@ -12,7 +12,6 @@ #include <vespa/searchsummary/docsummary/docsum_store_field_value.h> using search::docsummary::IDocsumStore; -using search::docsummary::ResType; namespace vsm { @@ -37,8 +36,6 @@ private: document::FieldValue::UP _cachedValue; document::FieldPath _emptyFieldPath; - DocsumFilter(const DocsumFilter &); - DocsumFilter &operator=(const DocsumFilter &); void prepareFieldSpec(DocsumFieldSpec & spec, const DocsumTools::FieldSpec & toolsSpec, const FieldMap & fieldMap, const FieldPathMapT & fieldPathMap); const document::FieldValue * getFieldValue(const DocsumFieldSpec::FieldIdentifier & fieldId, @@ -52,6 +49,8 @@ private: void insert_flattened_summary_field(const DocsumFieldSpec& field_spec, const Document& doc, vespalib::slime::Inserter& inserter); public: DocsumFilter(const DocsumToolsPtr & tools, const IDocSumCache & docsumCache); + DocsumFilter(const DocsumFilter &) = delete; + DocsumFilter &operator=(const DocsumFilter &) = delete; ~DocsumFilter() override; const DocsumToolsPtr & getTools() const { return _tools; } |