[ https://issues.apache.org/jira/browse/SOLR-5057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13718377#comment-13718377 ]
Yonik Seeley commented on SOLR-5057: ------------------------------------ I think the common case will be fqs being ordered (most fqs will be generated from a system and hence normally appear in the same order.) A few issues with this patch: - the sort is expensive - it generates hashcodes for elements on every single compare. - it's still not 100% - hashcodes for two different queries could match so sorting doesn't guarantee to get in the right order - it slows down the common case of ordered filters (the sort needs to be done even when just checking the cache too) How about this (untested) code instead: {code} // Do fast version, expecting that filters are ordered and only // fall back to unordered compare on the first non-equal elements. // This will only be called if the hash code of the entire key already // matched, so the slower unorderedCompare should pretty much never // be called if filter lists are generally ordered. private static boolean isEqual(List<Query> a, List<Query> b) { if (a==b) return true; // takes care of identity and null cases if (a==null || b==null) return false; int sz = a.size(); if (sz != b.size()) return false; for (int i=0; i<sz; i++) { if (!a.get(i).equals(b.get(i))) { return unorderedCompare(a, b, i); } } return true; } private static boolean unorderedCompare(List<Query> a, List<Query> b, int start) { int sz = a.size(); outer: for (int aIdx = start; aIdx<sz; aIdx++) { Query aQ = a.get(aIdx); for (int bIdx = start; bIdx<sz; bIdx++) { Query bQ =b.get(bIdx); if (aQ.equals(bQ)) continue outer; } return false; } return true; } {code} > queryResultCache should not related with the order of fq's list > --------------------------------------------------------------- > > Key: SOLR-5057 > URL: https://issues.apache.org/jira/browse/SOLR-5057 > Project: Solr > Issue Type: Improvement > Components: search > Affects Versions: 4.0, 4.1, 4.2, 4.3 > Reporter: Feihong Huang > Assignee: Erick Erickson > Priority: Minor > Attachments: SOLR-5057.patch, SOLR-5057.patch > > Original Estimate: 48h > Remaining Estimate: 48h > > There are two case query with the same meaning below. But the case2 can't use > the queryResultCache when case1 is executed. > case1: q=*:*&fq=field1:value1&fq=field2:value2 > case2: q=*:*&fq=field2:value2&fq=field1:value1 > I think queryResultCache should not be related with the order of fq's list. -- 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: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org