aboutsummaryrefslogtreecommitdiff
path: root/icing/index/iterator/doc-hit-info-iterator.h
diff options
context:
space:
mode:
authorTim Barron <tjbarron@google.com>2021-01-14 20:53:07 +0000
committerTim Barron <tjbarron@google.com>2021-01-14 20:53:07 +0000
commita34db390d80f862bfaaa49dea3605c5fec3bca3d (patch)
tree67a4a87803cf2b31619c3ddff3674967fc1461ce /icing/index/iterator/doc-hit-info-iterator.h
parent59c2caa38fd8dca3760dad751f4f8e5de8be25f5 (diff)
downloadicing-a34db390d80f862bfaaa49dea3605c5fec3bca3d.tar.gz
Update Icing from upstream.
Change-Id: I43038a59e7170fb8ecbaf6098a37221b3682ce09
Diffstat (limited to 'icing/index/iterator/doc-hit-info-iterator.h')
-rw-r--r--icing/index/iterator/doc-hit-info-iterator.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/icing/index/iterator/doc-hit-info-iterator.h b/icing/index/iterator/doc-hit-info-iterator.h
index bcc2b6e..c4d9901 100644
--- a/icing/index/iterator/doc-hit-info-iterator.h
+++ b/icing/index/iterator/doc-hit-info-iterator.h
@@ -17,6 +17,7 @@
#include <cstdint>
#include <string>
+#include <string_view>
#include "icing/text_classifier/lib3/utils/base/status.h"
#include "icing/text_classifier/lib3/utils/base/statusor.h"
@@ -28,6 +29,26 @@
namespace icing {
namespace lib {
+// Data structure that maps a single matched query term to its section mask
+// and the list of term frequencies.
+// TODO(b/158603837): add stat on whether the matched terms are prefix matched
+// or not. This information will be used to boost exact match.
+struct TermMatchInfo {
+ std::string_view term;
+ // SectionIdMask associated to the term.
+ SectionIdMask section_ids_mask;
+ // Array with fixed size kMaxSectionId. For every section id, i.e.
+ // vector index, it stores the term frequency of the term.
+ std::array<Hit::TermFrequency, kMaxSectionId> term_frequencies;
+
+ explicit TermMatchInfo(
+ std::string_view term, SectionIdMask section_ids_mask,
+ std::array<Hit::TermFrequency, kMaxSectionId> term_frequencies)
+ : term(term),
+ section_ids_mask(section_ids_mask),
+ term_frequencies(std::move(term_frequencies)) {}
+};
+
// Iterator over DocHitInfos (collapsed Hits) in REVERSE document_id order.
//
// NOTE: You must call Advance() before calling hit_info() or
@@ -70,6 +91,14 @@ class DocHitInfoIterator {
// A string representing the iterator.
virtual std::string ToString() const = 0;
+ // For the last hit docid, retrieves all the matched query terms and other
+ // stats, see TermMatchInfo.
+ // If Advance() wasn't called after construction, Advance() returned false or
+ // the concrete HitIterator didn't override this method, the vectors aren't
+ // populated.
+ virtual void PopulateMatchedTermsStats(
+ std::vector<TermMatchInfo>* matched_terms_stats) const {}
+
protected:
DocHitInfo doc_hit_info_;
SectionIdMask hit_intersect_section_ids_mask_ = kSectionIdMaskNone;