diff options
author | Tim Barron <tjbarron@google.com> | 2021-01-14 20:53:07 +0000 |
---|---|---|
committer | Tim Barron <tjbarron@google.com> | 2021-01-14 20:53:07 +0000 |
commit | a34db390d80f862bfaaa49dea3605c5fec3bca3d (patch) | |
tree | 67a4a87803cf2b31619c3ddff3674967fc1461ce /icing/index/lite | |
parent | 59c2caa38fd8dca3760dad751f4f8e5de8be25f5 (diff) | |
download | icing-a34db390d80f862bfaaa49dea3605c5fec3bca3d.tar.gz |
Update Icing from upstream.
Change-Id: I43038a59e7170fb8ecbaf6098a37221b3682ce09
Diffstat (limited to 'icing/index/lite')
-rw-r--r-- | icing/index/lite/doc-hit-info-iterator-term-lite.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/icing/index/lite/doc-hit-info-iterator-term-lite.h b/icing/index/lite/doc-hit-info-iterator-term-lite.h index bd2de6d..ac5e97f 100644 --- a/icing/index/lite/doc-hit-info-iterator-term-lite.h +++ b/icing/index/lite/doc-hit-info-iterator-term-lite.h @@ -49,6 +49,34 @@ class DocHitInfoIteratorTermLite : public DocHitInfoIterator { } int32_t GetNumLeafAdvanceCalls() const override { return num_advance_calls_; } + void PopulateMatchedTermsStats( + std::vector<TermMatchInfo>* matched_terms_stats) const override { + if (doc_hit_info_.document_id() == kInvalidDocumentId) { + // Current hit isn't valid, return. + return; + } + SectionIdMask section_mask = doc_hit_info_.hit_section_ids_mask(); + std::array<Hit::TermFrequency, kMaxSectionId> section_term_frequencies = { + Hit::kNoTermFrequency}; + while (section_mask) { + SectionId section_id = __builtin_ctz(section_mask); + section_term_frequencies.at(section_id) = + doc_hit_info_.hit_term_frequency(section_id); + section_mask &= ~(1u << section_id); + } + TermMatchInfo term_stats(term_, doc_hit_info_.hit_section_ids_mask(), + std::move(section_term_frequencies)); + + for (const TermMatchInfo& cur_term_stats : *matched_terms_stats) { + if (cur_term_stats.term == term_stats.term) { + // Same docId and same term, we don't need to add the term and the term + // frequency should always be the same + return; + } + } + matched_terms_stats->push_back(std::move(term_stats)); + } + protected: // Add DocHitInfos corresponding to term_ to cached_hits_. virtual libtextclassifier3::Status RetrieveMoreHits() = 0; |