[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-610) AndDocIdSet makeDocIdSetOnAgreedBits() returns wrong values
Hardy Ferentschik (JIRA)
noreply at atlassian.com
Tue Nov 2 12:39:47 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38987#action_38987 ]
Hardy Ferentschik commented on HSEARCH-610:
-------------------------------------------
The problem is that the {{DocIdSetIterator}} returned by {{SortedVIntList}} behaves differently when {{advance(int target)}} compared to the iterators returned by {{DocIdBitSet}} and {{OpenBitSet}}. Lets take the example from test test. Assume the following doc id are in the set 0, 5, 6 and 10. We get the {{DocIdSetIterator}} from the {{DocIdBitSet}} and we call {{next()}} until we point to the third element ({{iterator.docID() == 6}}. Now we call {{iterator.advance(6)}}.
The algorithm in {{AndDocIdSet}} assumes that the advance call will return 6, basically not moving to another element. This is also how {{DocIdBitSet}} and {{OpenBitSet}} behave. {{DocIdSetIterator}}, however, returns 10.
The question is who is right. The {{DocIdSetIterator.advance}} javadoc says:
{quote}
Advances to the first beyond the current whose document number is greater than or equal to _target_
{quote}
It also shows some pseudo code:
{code}
int advance(int target) {
int doc;
while ((doc = nextDoc()) < target) {
}
return doc;
}
{code}
Reading this documentation I would think {{SortedVIntList}} behaves correctly, but I think {{OpenBitSet}} is the more commonly used. I am surprised that no one has noticed this before.
On our {{AndDocIdSet}} side we can actually cater for this problem by comparing {{iterator.docID() == targetPosition}} before we call {{advance}}. If they match we don't have to call advance at all, because the iterator is already at the right position.
Need to follow up with the Lucene guys as well.
> AndDocIdSet makeDocIdSetOnAgreedBits() returns wrong values
> -----------------------------------------------------------
>
> Key: HSEARCH-610
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-610
> Project: Hibernate Search
> Issue Type: Bug
> Components: engine
> Affects Versions: 3.2.1, 3.3.0.Beta1
> Reporter: Christian Mader
> Assignee: Hardy Ferentschik
> Fix For: 3.3.0.CR1
>
> Attachments: AndDocIdSetTest.java
>
>
> Depending on the DocIdSets list, AndDocIdSet fails to compute correct values in makeDocIdSetOnAgreedBits(). Please see the attached test cases, test_middle() fails and in my opinion it shouldn't.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list