You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Jon Harper <jo...@gmail.com> on 2017/11/03 18:03:10 UTC

Potential bug in UsageTrackingQueryCachingPolicy

Hi,

I'm looking at lucene-core UsageTrackingQueryCachingPolicy.java (caching
policy for the LRUCache), one line of code looks dubious in the
shouldNeverCache method

The comment says "For the below queries, it's cheap to notice they cannot
match any docs so     we do not bother caching them. "  but then returns
false to shouldnevercache for MatchNoDocsQuery

Note that empty BooleanQuery and empty DisjunctionMaxQuery return true and
hence are never cached

Here's a github link to the line in question for easy and quick access.

https://github.com/apache/lucene-solr/blob/1d2787464f4709f4960716dd3314c7123324b15b/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java#L71


Regards,
Jon

Re: Potential bug in UsageTrackingQueryCachingPolicy

Posted by Adrien Grand <jp...@gmail.com>.
Hey Jon,

FYI I fixed this bug you reported at
https://issues.apache.org/jira/browse/LUCENE-8078. Thanks again for
reporting it.

Le lun. 20 nov. 2017 à 16:11, Adrien Grand <jp...@gmail.com> a écrit :

> Hi Jon,
>
> Sorry for the late reply. You are right that it should return true rather
> than false. Would you like to submit a patch?
>
> Le ven. 3 nov. 2017 à 19:04, Jon Harper <jo...@gmail.com> a écrit :
>
>> Hi,
>>
>> I'm looking at lucene-core UsageTrackingQueryCachingPolicy.java (caching
>> policy for the LRUCache), one line of code looks dubious in the
>> shouldNeverCache method
>>
>> The comment says "For the below queries, it's cheap to notice they cannot
>> match any docs so     we do not bother caching them. "  but then returns
>> false to shouldnevercache for MatchNoDocsQuery
>>
>> Note that empty BooleanQuery and empty DisjunctionMaxQuery return true
>> and hence are never cached
>>
>> Here's a github link to the line in question for easy and quick access.
>>
>>
>> https://github.com/apache/lucene-solr/blob/1d2787464f4709f4960716dd3314c7123324b15b/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java#L71
>>
>>
>> Regards,
>> Jon
>>
>

Re: Potential bug in UsageTrackingQueryCachingPolicy

Posted by Adrien Grand <jp...@gmail.com>.
Hi Jon,

Sorry for the late reply. You are right that it should return true rather
than false. Would you like to submit a patch?

Le ven. 3 nov. 2017 à 19:04, Jon Harper <jo...@gmail.com> a écrit :

> Hi,
>
> I'm looking at lucene-core UsageTrackingQueryCachingPolicy.java (caching
> policy for the LRUCache), one line of code looks dubious in the
> shouldNeverCache method
>
> The comment says "For the below queries, it's cheap to notice they cannot
> match any docs so     we do not bother caching them. "  but then returns
> false to shouldnevercache for MatchNoDocsQuery
>
> Note that empty BooleanQuery and empty DisjunctionMaxQuery return true and
> hence are never cached
>
> Here's a github link to the line in question for easy and quick access.
>
>
> https://github.com/apache/lucene-solr/blob/1d2787464f4709f4960716dd3314c7123324b15b/lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java#L71
>
>
> Regards,
> Jon
>