This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Implement TRUE Iterator
ClosedPublic

Authored by kbobyrev on Aug 20 2018, 1:10 AM.

Details

Summary

This patch introduces TRUE Iterator which efficiently handles posting lists containing all items within [0, Size) range.

Diff Detail

Repository
rL LLVM

Event Timeline

kbobyrev created this revision.Aug 20 2018, 1:10 AM
ioeric added inline comments.Aug 20 2018, 1:26 AM
clang-tools-extra/clangd/index/dex/Iterator.cpp
230 ↗(On Diff #161430)

nit: The documentation here is a bit verbose as. How about ... It stores size of the virtual posting list, and all operations are performed in O(1).? Other statements can be easily derived from this IMO.

248 ↗(On Diff #161430)

Should we check ID < Size here?

258 ↗(On Diff #161430)

nit: maybe s/TrueIterator/TRUE/?

kbobyrev updated this revision to Diff 161435.Aug 20 2018, 1:39 AM
kbobyrev marked 2 inline comments as done.

Address a couple of comments.

clang-tools-extra/clangd/index/dex/Iterator.cpp
248 ↗(On Diff #161430)

Not really, here's an example: (& ({0}, 42) (TRUE {0} out of 10).

When called advance(), underlying AND iterator would point to 42 and advanceTo() would be called on TRUE iterator, it will move it to the END but it would be completely valid (same behavior for every iterator, actually, since none of them check for ID < LastDocID equivalent).

I should, however, do Index = std::min(ID, Size) since calling dump() and getting something like (TRUE {9000} out of 42) would be implicit.

This revision is now accepted and ready to land.Aug 20 2018, 1:42 AM
This revision was automatically updated to reflect the committed changes.