mkhludnev commented on code in PR #2742: URL: https://github.com/apache/solr/pull/2742#discussion_r1808839272
########## solr/core/src/java/org/apache/solr/search/facet/FacetParser.java: ########## @@ -138,21 +139,30 @@ public Object parseFacetOrStat(String key, Object o) throws SyntaxError { return parseFacetOrStat(key, type, args); } + public interface ParseHandler { + Object doParse(FacetParser<?> parent, String key, Object args) throws SyntaxError; + } + + private static final Map<String, ParseHandler> REGISTERED_TYPES = new ConcurrentHashMap<>(); + + static { + ParseHandler fieldParser = (p, k, a) -> new FacetFieldParser(p, k).parse(a); + REGISTERED_TYPES.put("field", fieldParser); + REGISTERED_TYPES.put("terms", fieldParser); + REGISTERED_TYPES.put("query", (p, k, a) -> new FacetQueryParser(p, k).parse(a)); + REGISTERED_TYPES.put("range", (p, k, a) -> new FacetRangeParser(p, k).parse(a)); + REGISTERED_TYPES.put("heatmap", (p, k, a) -> new FacetHeatmap.Parser(p, k).parse(a)); + REGISTERED_TYPES.put("func", (p, k, a) -> p.parseStat(k, a)); + } + + public static void registerParseHandler(String type, ParseHandler parseHandler) { Review Comment: `REGISTERED_TYPES` are shared across cores. It means: - one core might inject a custom parser, it appears across all cores. If it hooks up some large state it remains in heap after core unloading (it might be called as a leak) - `registerPH` might be called with one of the standard name bringing some surprises to other cores. -- 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. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org