doc_iterator.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Tencent is pleased to support the open source community by making wwsearch
  3. * available.
  4. *
  5. * Copyright (C) 2018-present Tencent. All Rights Reserved.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  8. * use this file except in compliance with the License. You may obtain a copy of
  9. * the License at
  10. *
  11. * https://opensource.org/licenses/Apache-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OF ANY KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations under the License.
  17. */
  18. #pragma once
  19. #include "header.h"
  20. #include "storage_type.h"
  21. namespace wwsearch {
  22. /* Notice : Helper class for doc list iterator.
  23. * Support MergeIterator/OrIterator/DocListReaderCodec.
  24. * MergeIterator/OrIterator is used in Score to collect doc list.
  25. * DocListReaderCodec is used to read the doc list after codec(both
  26. * support fix-length format & variable format, distinguish with header version
  27. * flag).
  28. */
  29. class DocIdSetIterator {
  30. private:
  31. public:
  32. virtual ~DocIdSetIterator() {}
  33. static DocumentID NO_MORE_DOCS;
  34. static DocumentID MAX_DOCID;
  35. virtual DocumentID DocID() = 0;
  36. // If reac end {@link NO_MORE_DOCS} will return.
  37. virtual DocumentID NextDoc() = 0;
  38. // Seek to target or next one greater than target if target is not found.
  39. virtual DocumentID Advance(DocumentID target) = 0;
  40. virtual CostType Cost() = 0;
  41. virtual int FieldId() = 0;
  42. private:
  43. };
  44. } // namespace wwsearch