aboutsummaryrefslogtreecommitdiffstats
path: root/searchsummary
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2022-07-05 20:38:22 +0200
committerTor Egge <Tor.Egge@online.no>2022-07-05 20:38:22 +0200
commitd2b1b8857eb0f36a111af394509eca1a66d121b8 (patch)
treec4eafa305bf4086fa9df6add08b2446875a538e8 /searchsummary
parent93eb6426e14b015052c9b885ebd280aac9e545cb (diff)
Add insert_summary_field member function to IDoscumStoreDocument.
Diffstat (limited to 'searchsummary')
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.cpp15
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.h1
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/docsumfieldwriter.cpp15
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/docsumwriter.cpp28
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/general_result.h2
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/i_docsum_store_document.h3
6 files changed, 35 insertions, 29 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.cpp b/searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.cpp
index c0b894ddc0a..f97956be6da 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.cpp
@@ -1,6 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "docsum_store_document.h"
+#include "check_undefined_value_visitor.h"
+#include "summaryfieldconverter.h"
#include <vespa/document/datatype/datatype.h>
#include <vespa/document/fieldvalue/document.h>
@@ -28,4 +30,17 @@ DocsumStoreDocument::get_field_value(const vespalib::string& field_name) const
return {};
}
+void
+DocsumStoreDocument::insert_summary_field(const vespalib::string& field_name, vespalib::slime::Inserter& inserter) const
+{
+ auto field_value = get_field_value(field_name);
+ if (field_value) {
+ CheckUndefinedValueVisitor check_undefined;
+ field_value->accept(check_undefined);
+ if (!check_undefined.is_undefined()) {
+ SummaryFieldConverter::insert_summary_field(false, *field_value, inserter);
+ }
+ }
+}
+
}
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.h b/searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.h
index 4508132e7e0..66a5a74fa8d 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/docsum_store_document.h
@@ -18,6 +18,7 @@ public:
DocsumStoreDocument(std::unique_ptr<document::Document> document);
~DocsumStoreDocument() override;
std::unique_ptr<document::FieldValue> get_field_value(const vespalib::string& field_name) const override;
+ void insert_summary_field(const vespalib::string& field_name, vespalib::slime::Inserter& inserter) const override;
};
}
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsumfieldwriter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/docsumfieldwriter.cpp
index e70b094aa64..416526bead3 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/docsumfieldwriter.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/docsumfieldwriter.cpp
@@ -1,7 +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 "i_docsum_store_document.h"
#include "idocsumenvironment.h"
#include "docsumstate.h"
#include "summaryfieldconverter.h"
@@ -90,16 +90,11 @@ CopyDFW::insertField(uint32_t /*docid*/, GeneralResult *gres, GetDocsumsState *,
ResEntry *entry = gres->GetEntry(idx);
if (entry == nullptr) {
- auto input_field_value = gres->get_field_value(_input_field_name);
- if (input_field_value) {
- CheckUndefinedValueVisitor check_undefined;
- input_field_value->accept(check_undefined);
- if (!check_undefined.is_undefined()) {
- SummaryFieldConverter::insert_summary_field(false, *input_field_value, target);
- }
+ const auto* document = gres->get_document();
+ if (document != nullptr) {
+ document->insert_summary_field(_input_field_name, target);
}
- } else if (IsRuntimeCompatible(entry->_type, type))
- {
+ } else if (IsRuntimeCompatible(entry->_type, type)) {
switch (type) {
case RES_INT: {
uint32_t val32 = entry->_intval;
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsumwriter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/docsumwriter.cpp
index de8bb36e98b..a5ad577e240 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/docsumwriter.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/docsumwriter.cpp
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "docsumwriter.h"
-#include "check_undefined_value_visitor.h"
#include "docsumstate.h"
#include "docsum_field_writer_state.h"
+#include "i_docsum_store_document.h"
#include "summaryfieldconverter.h"
#include <vespa/document/fieldvalue/fieldvalue.h>
#include <vespa/searchcommon/common/undefinedvalues.h>
@@ -20,22 +20,6 @@ using vespalib::Issue;
namespace search::docsummary {
-namespace {
-
-void insert_document_field(const vespalib::string& field_name, const GeneralResult& gres, Inserter &inserter)
-{
- auto input_field_value = gres.get_field_value(field_name);
- if (input_field_value) {
- CheckUndefinedValueVisitor check_undefined;
- input_field_value->accept(check_undefined);
- if (!check_undefined.is_undefined()) {
- SummaryFieldConverter::insert_summary_field(false, *input_field_value, inserter);
- }
- }
-}
-
-}
-
uint32_t
IDocsumWriter::slime2RawBuf(const Slime & slime, RawBuf & buf)
{
@@ -116,7 +100,10 @@ static void convertEntry(const ResConfigEntry *resCfg,
LOG_ASSERT(resCfg != nullptr);
if (entry == nullptr || entry->_not_present) {
// Entry is not present in docsum blob
- insert_document_field(resCfg->_bindname, gres, inserter);
+ const auto* document = gres.get_document();
+ if (document != nullptr) {
+ document->insert_summary_field(resCfg->_bindname, inserter);
+ }
return;
}
@@ -220,7 +207,10 @@ DynamicDocsumWriter::insertDocsum(const ResolveClassInfo & rci, uint32_t docid,
LOG_ASSERT(entry != nullptr);
convertEntry(outCfg, entry, gres, inserter, slime);
} else {
- insert_document_field(outCfg->_bindname, gres, inserter);
+ const auto* document = gres.get_document();
+ if (document != nullptr) {
+ document->insert_summary_field(outCfg->_bindname, inserter);
+ }
}
}
}
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/general_result.h b/searchsummary/src/vespa/searchsummary/docsummary/general_result.h
index 93114dbb44d..f23d5ff5ea7 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/general_result.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/general_result.h
@@ -46,6 +46,8 @@ public:
return false;
}
}
+
+ const IDocsumStoreDocument *get_document() const noexcept { return _document; }
};
}
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/i_docsum_store_document.h b/searchsummary/src/vespa/searchsummary/docsummary/i_docsum_store_document.h
index 3fbf54b18a9..f81412eb34c 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/i_docsum_store_document.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/i_docsum_store_document.h
@@ -7,6 +7,8 @@
namespace document { class FieldValue; }
+namespace vespalib::slime { struct Inserter; }
+
namespace search::docsummary {
/**
@@ -19,6 +21,7 @@ class IDocsumStoreDocument
public:
virtual ~IDocsumStoreDocument() = default;
virtual std::unique_ptr<document::FieldValue> get_field_value(const vespalib::string& field_name) const = 0;
+ virtual void insert_summary_field(const vespalib::string& field_name, vespalib::slime::Inserter& inserter) const = 0;
};
}