[ https://issues.apache.org/jira/browse/LUCENE-5508?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Furkan KAMACI updated LUCENE-5508: ---------------------------------- Attachment: LUCENE-5508.patch I've attached the patch. I've also removed an unnecessary field too. > 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.8, 5.0 > > 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.2#6252) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org