[
https://issues.apache.org/jira/browse/LUCENE-9003?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16948579#comment-16948579
]
Uwe Schindler commented on LUCENE-9003:
---------------------------------------
+1 I had that issue also several times. Especially if you hide documents based
on a bitset or a query producing a bitset (e.g. filtered aliases, security
stuff using a BitsetProducer). Bitsets still require linear time to get their
cardinality.
The implementation and the lengthly comment about thread safety are perfectly
fine. But as numDocs is a seldomly used statistics (as you say), why not use
AtomicInteger with getOpaque()?
> Should FilterDirectoryReader compute numDocs lazily?
> ----------------------------------------------------
>
> Key: LUCENE-9003
> URL: https://issues.apache.org/jira/browse/LUCENE-9003
> Project: Lucene - Core
> Issue Type: Improvement
> Reporter: Adrien Grand
> Priority: Minor
> Time Spent: 10m
> Remaining Estimate: 0h
>
> FilterDirectoryReader extends BaseCompositeReader, which computes both maxDoc
> and numDocs eagerly in its constructor by summing up these values across all
> sub leaves.
> This is problematic for readers that hide additional documents. Computing
> numDocs on such leaf readers usually requires iterating over all live
> documents to count them. This makes creating a FilterDirectoryReader on top
> run in linear time, which has caused several performance bugs to us over
> time. This is especially frustrating given that numDocs is a rarely used
> index statistic.
> I think computing numDocs lazily would be less surprising?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]