[ 
https://issues.apache.org/jira/browse/LUCENE-1614?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12711576#action_12711576
 ] 

Michael McCandless commented on LUCENE-1614:
--------------------------------------------

bq. I think I'll emphasize that in the javadocs, documenting the limitation of 
MAX_VAL so that people won't assume the wrong things.

+1

A docID is different from an "int", because docIDs must be 0 .. MAX_VAL-1.

{quote}
Why? just because OBSI declared a method which we wanted anyway? You know .. 
it's something we don't give much thought to when we add methods to abstract 
classes, but what if someone extended DISI and added his own advance(int) or 
nextDoc() which don't behave like we expect them to. When he'll pass his DISI 
to the search flow somehow, not knowing these have become the primary methods, 
something will break.

I'm not saying we should protect these cases too, because otherwise we won't be 
able to make any changes. But just because OBSI had nextDoc() declared doesn't 
mean we should go and find a different name. That's slightly unrelated to this 
issue, but our back-compat policy forces us to replace good names with moderate 
ones, just because we cannot change methods.
{quote}

You're right, a random subclass of an abstract class could very well choose the 
name we are wanting to add, and then their class fails to compile, or (if the 
sigs turn out to be identical) runs bug possibly causes problems.

But in this case we know we have just such a class that has done so (OBSI).  
And of course it did so for exactly the reasons that we are now wanting to add 
nextDoc to DISI.  My guess is eg Solr probably relies heavily on OBSI.nextDoc 
returning -1 when it's done and we're gonna cause AIOOB exceptions if we up and 
change to returning MAX_VAL.

bq.  That's slightly unrelated to this issue, but our back-compat policy forces 
us to replace good names with moderate ones, just because we cannot change 
methods.

As much as it bothers me having to accept inferior names (so they don't 
conflict with the existing names), I think it's very much the lesser-of-evils 
here.

> Add next() and skipTo() variants to DocIdSetIterator that return the current 
> doc, instead of boolean
> ----------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-1614
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1614
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Search
>            Reporter: Shai Erera
>             Fix For: 2.9
>
>         Attachments: LUCENE-1614.patch
>
>
> See 
> http://www.nabble.com/Another-possible-optimization---now-in-DocIdSetIterator-p23223319.html
>  for the full discussion. The basic idea is to add variants to those two 
> methods that return the current doc they are at, to save successive calls to 
> doc(). If there are no more docs, return -1. A summary of what was discussed 
> so far:
> # Deprecate those two methods.
> # Add nextDoc() and skipToDoc(int) that return doc, with default impl in DISI 
> (calls next() and skipTo() respectively, and will be changed to abstract in 
> 3.0).
> #* I actually would like to propose an alternative to the names: advance() 
> and advance(int) - the first advances by one, the second advances to target.
> # Wherever these are used, do something like '(doc = advance()) >= 0' instead 
> of comparing to -1 for improved performance.
> I will post a patch shortly

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to