gautamworah96 commented on a change in pull request #2247: URL: https://github.com/apache/lucene-solr/pull/2247#discussion_r566981233
########## File path: lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java ########## @@ -353,12 +349,65 @@ public FacetLabel getPath(int ordinal) throws IOException { } synchronized (categoryCache) { - categoryCache.put(catIDInteger, ret); + categoryCache.put(ordinal, ret); } return ret; } + private FacetLabel getPathFromCache(int ordinal) { + ensureOpen(); + + // TODO: can we use an int-based hash impl, such as IntToObjectMap, + // wrapped as LRU? + synchronized (categoryCache) { + FacetLabel res = categoryCache.get(ordinal); + if (res != null) { + return res; + } + } + return null; + } + + /* This API is only supported for indexes created with Lucene 8.7+ codec **/ + public FacetLabel[] getBulkPath(int[] ordinal) throws IOException { + FacetLabel[] bulkPath = new FacetLabel[ordinal.length]; + Map<Integer, Integer> originalPosition = new HashMap<>(); + for (int i = 0; i < ordinal.length; i++) { + if (ordinal[i] < 0 || ordinal[i] >= indexReader.maxDoc()) { + return null; + } + FacetLabel ordinalPath = getPathFromCache(ordinal[i]); + if (ordinalPath != null) { + bulkPath[i] = ordinalPath; + } + originalPosition.put(ordinal[i], i); Review comment: Hmmm. I think using a map to remember initial positions is still simpler to understand? or I could still change it in the next revision ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org