1 // Copyright (C) 2023 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef ICING_INDEX_ITERATOR_DOC_HIT_INFO_ITERATOR_NONE_H_ 16 #define ICING_INDEX_ITERATOR_DOC_HIT_INFO_ITERATOR_NONE_H_ 17 18 #include <cstdint> 19 #include <string> 20 21 #include "icing/text_classifier/lib3/utils/base/status.h" 22 #include "icing/absl_ports/canonical_errors.h" 23 #include "icing/index/iterator/doc-hit-info-iterator.h" 24 25 namespace icing { 26 namespace lib { 27 28 // Iterator that will return no results. 29 class DocHitInfoIteratorNone : public DocHitInfoIterator { 30 public: Advance()31 libtextclassifier3::Status Advance() override { 32 return absl_ports::ResourceExhaustedError( 33 "DocHitInfoIterator NONE has no hits."); 34 } 35 TrimRightMostNode()36 libtextclassifier3::StatusOr<TrimmedNode> TrimRightMostNode() && override { 37 TrimmedNode node = {nullptr, /*term=*/"", /*term_start_index_=*/0, 38 /*unnormalized_term_length_=*/0}; 39 return node; 40 } 41 MapChildren(const ChildrenMapper & mapper)42 void MapChildren(const ChildrenMapper& mapper) override {} 43 GetCallStats()44 CallStats GetCallStats() const override { return CallStats(); } 45 ToString()46 std::string ToString() const override { return "(NONE)"; } 47 }; 48 49 } // namespace lib 50 } // namespace icing 51 52 #endif // ICING_INDEX_ITERATOR_DOC_HIT_INFO_ITERATOR_NONE_H_ 53