diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-07-01 14:11:18 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-07-01 14:11:18 +0200 |
commit | 36cf61ddf65115ec0a3de958fdef6c656c337079 (patch) | |
tree | 246c94e1d80b1768fd68d8d4aeaebe084a1a261c /searchsummary | |
parent | 8541f542bbfed01d8aabf5eb87842c13e0649bc2 (diff) |
Empty docsummary output for undefined value.
Diffstat (limited to 'searchsummary')
4 files changed, 187 insertions, 1 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt b/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt index 1f6004111cc..4a5648d0842 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt +++ b/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt @@ -5,6 +5,7 @@ vespa_add_library(searchsummary_docsummary OBJECT attribute_combiner_dfw.cpp attribute_field_writer.cpp attributedfw.cpp + check_undefined_value_visitor.cpp docsumconfig.cpp docsumfieldwriter.cpp docsumstate.cpp diff --git a/searchsummary/src/vespa/searchsummary/docsummary/check_undefined_value_visitor.cpp b/searchsummary/src/vespa/searchsummary/docsummary/check_undefined_value_visitor.cpp new file mode 100644 index 00000000000..ff3ebbd66fc --- /dev/null +++ b/searchsummary/src/vespa/searchsummary/docsummary/check_undefined_value_visitor.cpp @@ -0,0 +1,140 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "check_undefined_value_visitor.h" +#include <vespa/searchcommon/common/undefinedvalues.h> +#include <vespa/document/fieldvalue/fieldvalues.h> + +using search::attribute::isUndefined; + + +namespace search::docsummary { + +void +CheckUndefinedValueVisitor::visit(const document::AnnotationReferenceFieldValue&) +{ +} + +void +CheckUndefinedValueVisitor::visit(const document::ArrayFieldValue& value) +{ + if (value.isEmpty()) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::BoolFieldValue&) +{ +} + +void +CheckUndefinedValueVisitor::visit(const document::ByteFieldValue& value) +{ + if (isUndefined(value.getValue())) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::Document&) +{ +} + +void +CheckUndefinedValueVisitor::visit(const document::DoubleFieldValue& value) +{ + if (isUndefined(value.getValue())) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::FloatFieldValue& value) +{ + if (isUndefined(value.getValue())) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::IntFieldValue& value) +{ + if (isUndefined(value.getValue())) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::LongFieldValue& value) +{ + if (isUndefined(value.getValue())) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::MapFieldValue& value) +{ + if (value.isEmpty()) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::PredicateFieldValue&) +{ +} + +void +CheckUndefinedValueVisitor::visit(const document::RawFieldValue&) +{ +} + +void +CheckUndefinedValueVisitor::visit(const document::ShortFieldValue& value) +{ + if (isUndefined(value.getValue())) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::StringFieldValue& value) +{ + if (isUndefined(value.getValue())) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::StructFieldValue&) +{ +} + +void +CheckUndefinedValueVisitor::visit(const document::WeightedSetFieldValue& value) +{ + if (value.isEmpty()) { + _is_undefined = true; + } +} + +void +CheckUndefinedValueVisitor::visit(const document::TensorFieldValue&) +{ +} + +void +CheckUndefinedValueVisitor::visit(const document::ReferenceFieldValue&) +{ +} + +CheckUndefinedValueVisitor::CheckUndefinedValueVisitor() + : _is_undefined(false) +{ +} + + +CheckUndefinedValueVisitor::~CheckUndefinedValueVisitor() = default; + +} diff --git a/searchsummary/src/vespa/searchsummary/docsummary/check_undefined_value_visitor.h b/searchsummary/src/vespa/searchsummary/docsummary/check_undefined_value_visitor.h new file mode 100644 index 00000000000..0fb6f7ed1c4 --- /dev/null +++ b/searchsummary/src/vespa/searchsummary/docsummary/check_undefined_value_visitor.h @@ -0,0 +1,40 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/document/fieldvalue/fieldvaluevisitor.h> + +namespace search::docsummary { + +/* + * This class checks if field value is considered the same value as undefined + * values for attribute vectors. + */ +class CheckUndefinedValueVisitor : public document::ConstFieldValueVisitor +{ + bool _is_undefined; + void visit(const document::AnnotationReferenceFieldValue&) override; + void visit(const document::ArrayFieldValue& value) override; + void visit(const document::BoolFieldValue&) override; + void visit(const document::ByteFieldValue& value) override; + void visit(const document::Document&) override; + void visit(const document::DoubleFieldValue& value) override; + void visit(const document::FloatFieldValue& value) override; + void visit(const document::IntFieldValue& value) override; + void visit(const document::LongFieldValue& value) override; + void visit(const document::MapFieldValue& value) override; + void visit(const document::PredicateFieldValue&) override; + void visit(const document::RawFieldValue&) override; + void visit(const document::ShortFieldValue& value) override; + void visit(const document::StringFieldValue& value) override; + void visit(const document::StructFieldValue&) override; + void visit(const document::WeightedSetFieldValue& value) override; + void visit(const document::TensorFieldValue&) override; + void visit(const document::ReferenceFieldValue&) override; +public: + CheckUndefinedValueVisitor(); + ~CheckUndefinedValueVisitor() override; + bool is_undefined() const noexcept { return _is_undefined; } +}; + +} diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsumfieldwriter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/docsumfieldwriter.cpp index 10b51e1f8e5..e70b094aa64 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/docsumfieldwriter.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/docsumfieldwriter.cpp @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "docsumfieldwriter.h" +#include "check_undefined_value_visitor.h" #include "idocsumenvironment.h" #include "docsumstate.h" #include "summaryfieldconverter.h" @@ -91,7 +92,11 @@ CopyDFW::insertField(uint32_t /*docid*/, GeneralResult *gres, GetDocsumsState *, if (entry == nullptr) { auto input_field_value = gres->get_field_value(_input_field_name); if (input_field_value) { - SummaryFieldConverter::insert_summary_field(false, *input_field_value, target); + CheckUndefinedValueVisitor check_undefined; + input_field_value->accept(check_undefined); + if (!check_undefined.is_undefined()) { + SummaryFieldConverter::insert_summary_field(false, *input_field_value, target); + } } } else if (IsRuntimeCompatible(entry->_type, type)) { |