Mailing List Archive

skipTo()
Greetings,

Doesn't this implementation of skipTo(int target) fail when the TermDocs
is already set on the target?
I got this one out of SegmentsTermDocs in SegmentsReader.java, but I
think there are many copies of this code in other places.

======================
public boolean skipTo(int target) throws IOException {
do {
if (!next())
return false;
} while (target > doc());
return true;
}
======================
RE: skipTo() [ In reply to ]
This would be hard to fix without modifying the TermDocs API. This could be
construed as just a documentation problem. Perhaps this method should be
documented so that 'target' must be strictly greater than the current
document.

Doug

> -----Original Message-----
> From: Dmitry Serebrennikov [mailto:dmitrys@earthlink.net]
> Sent: Wednesday, October 10, 2001 6:30 PM
> To: lucene-dev@jakarta.apache.org
> Subject: skipTo()
>
>
> Greetings,
>
> Doesn't this implementation of skipTo(int target) fail when
> the TermDocs
> is already set on the target?
> I got this one out of SegmentsTermDocs in SegmentsReader.java, but I
> think there are many copies of this code in other places.
>
> ======================
> public boolean skipTo(int target) throws IOException {
> do {
> if (!next())
> return false;
> } while (target > doc());
> return true;
> }
> ======================
>
Re: skipTo() [ In reply to ]
Yes, I realized that after I sent the message. Maybe there is a need for
a convinence method that checks the current doc first and then calls
skipTo if needed.

Doug Cutting wrote:

>This would be hard to fix without modifying the TermDocs API. This could be
>construed as just a documentation problem. Perhaps this method should be
>documented so that 'target' must be strictly greater than the current
>document.
>
>Doug
>
>>-----Original Message-----
>>From: Dmitry Serebrennikov [mailto:dmitrys@earthlink.net]
>>Sent: Wednesday, October 10, 2001 6:30 PM
>>To: lucene-dev@jakarta.apache.org
>>Subject: skipTo()
>>
>>
>>Greetings,
>>
>>Doesn't this implementation of skipTo(int target) fail when
>>the TermDocs
>>is already set on the target?
>>I got this one out of SegmentsTermDocs in SegmentsReader.java, but I
>>think there are many copies of this code in other places.
>>
>>======================
>> public boolean skipTo(int target) throws IOException {
>> do {
>> if (!next())
>> return false;
>> } while (target > doc());
>> return true;
>> }
>>======================
>>
>