summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/index/dex/Iterator.cpp
diff options
context:
space:
mode:
authorKirill Bobyrev <kbobyrev.opensource@gmail.com>2018-09-13 17:11:03 +0000
committerKirill Bobyrev <kbobyrev.opensource@gmail.com>2018-09-13 17:11:03 +0000
commit249c5864cf9657a320e427318a879ba809e84b1a (patch)
tree3a612c6ebb5068f20541582a528912a71e91d7b3 /clang-tools-extra/clangd/index/dex/Iterator.cpp
parentf29b36c76d6452180957472ac62a65507d822301 (diff)
downloadbcm5719-llvm-249c5864cf9657a320e427318a879ba809e84b1a.tar.gz
bcm5719-llvm-249c5864cf9657a320e427318a879ba809e84b1a.zip
[clangd] Introduce PostingList interface
This patch abstracts `PostingList` interface and reuses existing implementation. It will be used later to test different `PostingList` representations. No functionality change is introduced, this patch is mostly refactoring so that the following patches could focus on functionality while not being too hard to review. Reviewed By: sammccall, ioeric Differential Revision: https://reviews.llvm.org/D51982 llvm-svn: 342155
Diffstat (limited to 'clang-tools-extra/clangd/index/dex/Iterator.cpp')
-rw-r--r--clang-tools-extra/clangd/index/dex/Iterator.cpp67
1 files changed, 0 insertions, 67 deletions
diff --git a/clang-tools-extra/clangd/index/dex/Iterator.cpp b/clang-tools-extra/clangd/index/dex/Iterator.cpp
index 8d5527205b3..06d778dd503 100644
--- a/clang-tools-extra/clangd/index/dex/Iterator.cpp
+++ b/clang-tools-extra/clangd/index/dex/Iterator.cpp
@@ -18,69 +18,6 @@ namespace dex {
namespace {
-/// Implements Iterator over a PostingList. DocumentIterator is the most basic
-/// iterator: it doesn't have any children (hence it is the leaf of iterator
-/// tree) and is simply a wrapper around PostingList::const_iterator.
-class DocumentIterator : public Iterator {
-public:
- explicit DocumentIterator(PostingListRef Documents)
- : Documents(Documents), Index(std::begin(Documents)) {}
-
- bool reachedEnd() const override { return Index == std::end(Documents); }
-
- /// Advances cursor to the next item.
- void advance() override {
- assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
- ++Index;
- }
-
- /// Applies binary search to advance cursor to the next item with DocID equal
- /// or higher than the given one.
- void advanceTo(DocID ID) override {
- assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end.");
- // If current ID is beyond requested one, iterator is already in the right
- // state.
- if (peek() < ID)
- Index = std::lower_bound(Index, std::end(Documents), ID);
- }
-
- DocID peek() const override {
- assert(!reachedEnd() && "DOCUMENT iterator can't peek() at the end.");
- return *Index;
- }
-
- float consume() override {
- assert(!reachedEnd() && "DOCUMENT iterator can't consume() at the end.");
- return DEFAULT_BOOST_SCORE;
- }
-
- size_t estimateSize() const override { return Documents.size(); }
-
-private:
- llvm::raw_ostream &dump(llvm::raw_ostream &OS) const override {
- OS << '[';
- auto Separator = "";
- for (auto It = std::begin(Documents); It != std::end(Documents); ++It) {
- OS << Separator;
- if (It == Index)
- OS << '{' << *It << '}';
- else
- OS << *It;
- Separator = ", ";
- }
- OS << Separator;
- if (Index == std::end(Documents))
- OS << "{END}";
- else
- OS << "END";
- OS << ']';
- return OS;
- }
-
- PostingListRef Documents;
- PostingListRef::const_iterator Index;
-};
-
/// Implements Iterator over the intersection of other iterators.
///
/// AndIterator iterates through common items among all children. It becomes
@@ -399,10 +336,6 @@ std::vector<std::pair<DocID, float>> consume(Iterator &It) {
return Result;
}
-std::unique_ptr<Iterator> create(PostingListRef Documents) {
- return llvm::make_unique<DocumentIterator>(Documents);
-}
-
std::unique_ptr<Iterator>
createAnd(std::vector<std::unique_ptr<Iterator>> Children) {
// If there is exactly one child, pull it one level up: AND(Child) -> Child.
OpenPOWER on IntegriCloud