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

Robert Muir commented on LUCENE-4874:
-------------------------------------

{quote}
shouldn't IndexReader.hasDeletions return numDeletedDocs() > 0 by default 
instead of being abstract?
{quote}

I fell into this trap myself before (naively providing a fake livedocs to a 
filterreader), there are quite a few traps and inconsistencies:
* if you override the livedocs you currently need to override a bunch of other 
things too (e.g. hasDeletions, numDocs). we should at least add a javadoc to 
FilterAtomicReader make it less trappy.
* hasDeletions is abstract, and its easy to forget to implement this.
* SegmentReader says that for hasDeletions/numDocs/maxDoc "Don't call 
ensureOpen() here (it could affect performance)". But FilterAtomicReader only 
says this for numDocs and maxDoc and calls it on hasDeletions!
* default implementation in SegmentReader uses liveDocs != null: but i dont 
know anything checking (e.g. CheckIndex should do this) that the codec's 
LiveDocsFormat must return null (vs a Bits matching all docs). We should check 
this if there is code actually making this (undocumented) assumption.

For SegmentReader at least, it seems to be better if it had this 
implementation: and neither numDocs() and maxDocs() calls ensureOpen() either 
so I only see it as a safer way to go (we could avoid the sketchy liveDocs != 
null, but i bet other code elsewhere relies on this too).

{quote}
isn't the default impl of TermsEnum.termState dangerous? Shouldn't it throw an 
UnsupportedOperationException or being abstract instead?
{quote}

I don't know whats going on here: but I agree. it seems the current default 
implementation is "silently wont work".

                
> Remove FilterTerms.intersect
> ----------------------------
>
>                 Key: LUCENE-4874
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4874
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Adrien Grand
>            Priority: Minor
>
> Terms.intersect is an optional method. The fact that it is overridden in 
> FilterTerms forces any non-trivial class that extends FilterTerms to override 
> intersect in order this method to have a correct behavior. If FilterTerms did 
> not override this method and used the default impl, we would not have this 
> problem.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to