aboutsummaryrefslogtreecommitdiff
path: root/icing/index/lite
diff options
context:
space:
mode:
authorAlexander Dorokhine <adorokhine@google.com>2021-08-13 11:07:18 -0700
committerAlexander Dorokhine <adorokhine@google.com>2021-08-13 11:07:18 -0700
commit71eeeb436ec794daef5187d12ca9aba2c5773d7d (patch)
tree5129f3a74eb616eb2856c6db3392011c1ce384f8 /icing/index/lite
parent40c7203fab1d491f62f223fad10eddc180605729 (diff)
downloadicing-71eeeb436ec794daef5187d12ca9aba2c5773d7d.tar.gz
Merge androidx-platform-dev/external/icing upstream-master into upstream-master
Change-Id: Id39bea14b3a3d378d722dc552e4f3bd4249f3f94
Diffstat (limited to 'icing/index/lite')
-rw-r--r--icing/index/lite/doc-hit-info-iterator-term-lite.cc9
-rw-r--r--icing/index/lite/doc-hit-info-iterator-term-lite.h5
-rw-r--r--icing/index/lite/lite-index.cc2
-rw-r--r--icing/index/lite/lite-index.h3
4 files changed, 15 insertions, 4 deletions
diff --git a/icing/index/lite/doc-hit-info-iterator-term-lite.cc b/icing/index/lite/doc-hit-info-iterator-term-lite.cc
index d535d7f..08df4fc 100644
--- a/icing/index/lite/doc-hit-info-iterator-term-lite.cc
+++ b/icing/index/lite/doc-hit-info-iterator-term-lite.cc
@@ -45,8 +45,13 @@ libtextclassifier3::Status DocHitInfoIteratorTermLite::Advance() {
if (cached_hits_idx_ == -1) {
libtextclassifier3::Status status = RetrieveMoreHits();
if (!status.ok()) {
- ICING_LOG(ERROR) << "Failed to retrieve more hits "
- << status.error_message();
+ if (!absl_ports::IsNotFound(status)) {
+ // NOT_FOUND is expected to happen (not every term will be in the main
+ // index!). Other errors are worth logging.
+ ICING_LOG(ERROR)
+ << "Encountered unexpected failure while retrieving hits "
+ << status.error_message();
+ }
return absl_ports::ResourceExhaustedError(
"No more DocHitInfos in iterator");
}
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 8dbe043..179fc93 100644
--- a/icing/index/lite/doc-hit-info-iterator-term-lite.h
+++ b/icing/index/lite/doc-hit-info-iterator-term-lite.h
@@ -82,6 +82,11 @@ class DocHitInfoIteratorTermLite : public DocHitInfoIterator {
protected:
// Add DocHitInfos corresponding to term_ to cached_hits_.
+ //
+ // Returns:
+ // - OK, on success
+ // - NOT_FOUND if no term matching term_ was found in the lexicon.
+ // - INVALID_ARGUMENT if unable to properly encode the termid
virtual libtextclassifier3::Status RetrieveMoreHits() = 0;
const std::string term_;
diff --git a/icing/index/lite/lite-index.cc b/icing/index/lite/lite-index.cc
index 69138e1..fb23934 100644
--- a/icing/index/lite/lite-index.cc
+++ b/icing/index/lite/lite-index.cc
@@ -310,8 +310,6 @@ libtextclassifier3::Status LiteIndex::AddHit(uint32_t term_id, const Hit& hit) {
return absl_ports::ResourceExhaustedError("Hit buffer is full!");
}
- header_->set_last_added_docid(hit.document_id());
-
TermIdHitPair term_id_hit_pair(term_id, hit);
uint32_t cur_size = header_->cur_size();
TermIdHitPair::Value* valp =
diff --git a/icing/index/lite/lite-index.h b/icing/index/lite/lite-index.h
index 90c6fbc..b134aba 100644
--- a/icing/index/lite/lite-index.h
+++ b/icing/index/lite/lite-index.h
@@ -225,6 +225,9 @@ class LiteIndex {
DocumentId last_added_document_id() const {
return header_->last_added_docid();
}
+ void set_last_added_document_id(DocumentId document_id) const {
+ header_->set_last_added_docid(document_id);
+ }
const IcingDynamicTrie& lexicon() const { return lexicon_; }