[ https://issues.apache.org/jira/browse/LUCENE-5508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14984582#comment-14984582 ]
Daniel Jelinski commented on LUCENE-5508: ----------------------------------------- This issue belongs to Solr, not Lucene JIRA. The problem is still present. The patch looks good to me (except removing the unused field should probably be a separate patch), but it no longer applies to the trunk. > Unnecessary Check and Assgiment at FieldFacetStats > -------------------------------------------------- > > Key: LUCENE-5508 > URL: https://issues.apache.org/jira/browse/LUCENE-5508 > Project: Lucene - Core > Issue Type: Bug > Affects Versions: 4.6.1, 4.7 > Reporter: Furkan KAMACI > Priority: Minor > Fix For: 4.9, Trunk > > Attachments: LUCENE-5508.patch > > > Here is the code: > {code} > int term = topLevelSortedValues.getOrd(docID); > int arrIdx = term; > if (arrIdx >= 0 && arrIdx < topLevelSortedValues.getValueCount()) { > final BytesRef br; > if (term == -1) { > br = null; > } else { > br = tempBR; > topLevelSortedValues.lookupOrd(term, tempBR); > } > String key = br == null ? null : br.utf8ToString(); > while (facetStatsTerms.size() <= statsTermNum) { > facetStatsTerms.add(new HashMap<String, Integer>()); > } > final Map<String, Integer> statsTermCounts = > facetStatsTerms.get(statsTermNum); > Integer statsTermCount = statsTermCounts.get(key); > if (statsTermCount == null) { > statsTermCounts.put(key, 1); > } else { > statsTermCounts.put(key, statsTermCount + 1); > } > return true; > } > {code} > There is a check condition for: > {code} > arrIdx >= 0 > {code} > but there is an unnecessary check condition after it: > {code} > if (term == -1) { > br = null; > } else { > br = tempBR; > topLevelSortedValues.lookupOrd(term, tempBR); > } > {code} > because arrIdx is equals to term and greater or equals to 0 within that code > part. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org