diff options
author | Geir Storli <geirst@verizonmedia.com> | 2019-12-03 13:21:46 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2019-12-03 13:21:46 +0000 |
commit | d4c31895cebab476ed8fb1c6833d30fc2c918bf2 (patch) | |
tree | 9de9b8a18070974ce04537e8dbdf58ee9382c5e9 /searchsummary | |
parent | 06fc5a871482470cebf6315dc47342b0cbc06900 (diff) |
Expose the document instance that was used to generate a docsum blob.
Diffstat (limited to 'searchsummary')
3 files changed, 51 insertions, 2 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt b/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt index 0152da26a7f..b5ce0a0619c 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt +++ b/searchsummary/src/vespa/searchsummary/docsummary/CMakeLists.txt @@ -8,6 +8,7 @@ vespa_add_library(searchsummary_docsummary OBJECT docsumconfig.cpp docsumfieldwriter.cpp docsumstate.cpp + docsumstorevalue.cpp docsumwriter.cpp dynamicteaserdfw.cpp general_result.cpp diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsumstorevalue.cpp b/searchsummary/src/vespa/searchsummary/docsummary/docsumstorevalue.cpp new file mode 100644 index 00000000000..8ce986f6a16 --- /dev/null +++ b/searchsummary/src/vespa/searchsummary/docsummary/docsumstorevalue.cpp @@ -0,0 +1,28 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "docsumstorevalue.h" +#include <vespa/document/fieldvalue/document.h> + +namespace search::docsummary { + +DocsumStoreValue::DocsumStoreValue() + : _value(static_cast<const char*>(0), 0), + _document() +{ +} + +DocsumStoreValue::DocsumStoreValue(const char *pt_, uint32_t len_) + : _value(pt_, len_), + _document() +{ +} + +DocsumStoreValue::DocsumStoreValue(const char *pt_, uint32_t len_, std::unique_ptr<document::Document> document_) + : _value(pt_, len_), + _document(std::move(document_)) +{ +} + +DocsumStoreValue::~DocsumStoreValue() = default; + +} diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsumstorevalue.h b/searchsummary/src/vespa/searchsummary/docsummary/docsumstorevalue.h index a15fb6d8892..4cb04c452a9 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/docsumstorevalue.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/docsumstorevalue.h @@ -2,8 +2,11 @@ #pragma once #include <cstdint> +#include <memory> #include <utility> +namespace document { class Document; } + namespace search::docsummary { /** @@ -16,20 +19,35 @@ class DocsumStoreValue { private: std::pair<const char *, uint32_t> _value; + // The document instance that was used to generate the docsum blob. + // Note: This is temporary until the docsummary framework is simplified, + // and the docsum blob concept is removed. + std::unique_ptr<document::Document> _document; public: /** * Construct object representing an empty docsum blob. **/ - DocsumStoreValue() : _value(static_cast<const char*>(0), 0) {} + DocsumStoreValue(); + + /** + * Construct object encapsulating the given location and size. + * + * @param pt_ docsum location + * @param len_ docsum size + **/ + DocsumStoreValue(const char *pt_, uint32_t len_); /** * Construct object encapsulating the given location and size. * * @param pt_ docsum location * @param len_ docsum size + * @param document_ document instance used to generate the docsum blob **/ - DocsumStoreValue(const char *pt_, uint32_t len_) : _value(pt_, len_) {} + DocsumStoreValue(const char *pt_, uint32_t len_, std::unique_ptr<document::Document> document_); + + ~DocsumStoreValue(); /** * @return docsum blob location @@ -55,6 +73,8 @@ public: * @return true if this has a valid blob **/ bool valid() const { return (_value.first != 0) && (_value.second >= sizeof(uint32_t)); } + + const document::Document* get_document() const { return _document.get(); } }; } |