Fix missing postings in Merge and Intersect (#77)
* Test for a previous implematation of Intersect Before we were moving the postings list everytime we create a new chained `intersectPostings`. That was causing some postings to be skipped. This test fails on the older version. Signed-off-by: NGoutham Veeramachaneni <cs14btech11014@iith.ac.in> * Advance on Seek only when valid. Issue: Before in mergedPostings and others we advance everytime we `Seek`, which causes issues with `Intersect`. Take the case, where we have a mergedPostings = m merging, a: {10, 20, 30} and b: {15, 25, 35}. Everytime we `Seek`, we do a.Seek and b.Seek. Now if we Intersect m with {21, 22, 23, 30}, we would do Seek({21,22,23}) which would advance a and b beyond 30. Fix: Now we advance only when the seeking value is greater than the current value, as the definition specifies. Also, posting 0 will not be a valid posting and will be used to signal finished or un-initialized PostingsList. Signed-off-by: NGoutham Veeramachaneni <cs14btech11014@iith.ac.in> * Add test for Merge+Intersect edgecase. Signed-off-by: NGoutham Veeramachaneni <cs14btech11014@iith.ac.in> * Add comments to trivial tests. Signed-off-by: NGoutham Veeramachaneni <cs14btech11014@iith.ac.in>
Showing
想要评论请 注册 或 登录