[
https://issues.apache.org/jira/browse/SOLR-4872?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13681802#comment-13681802
]
Hoss Man commented on SOLR-4872:
--------------------------------
This issue seems to have gotten really convoluted and confusing, so lemme type
my understanding of what's going on here to see if it clears things up for
people (or if i myself am totally misunderstanding)...
* Benson filed an issue requesting that Solr allow "analyzers" to be
SolrCoreAware
** the (entire?) motivation for this apparently being that he wants to be able
to register a CloseHook with the SolrCore that can do some housekeeping when
it's no longer needed (ie: the SolrCore is closed)
** ie: Benson doesn't actually seem to specifically want/need access to the
SolrCore in his analysis code, he just wants some mechanism to cleanup stuff
and having SolrCoreAware+CloseHook would give him a mechanism ... (XY Problem?)
* Benson said "analyzer" in the summary of the issue, but what he really ment
was
analysis *factories*
* then there was some confusion about Tokenizer.close(), and a ref to
LUCENE-2145 (which i suspect isn't particularly applicable since it's pretty
old and the APIs have evolved heavily since then)
** Rob pointed out that Tokenizer.close() probably shouldn't close the reader,
that should be the callers job -- this seems like a completely independent
discussion that should happen in another more specific Jira
** all of this seems like a red herring to the matter at hand since, as
mentioned above, what (seems to be) really desired is a way for the *factories*
to be able to create some data reused by multiple instances those factories
create, and then clean that data up in a responsible manner.
----
Does that sound like an accurate summary of things so far?
I think rob hit the nail on the head with part of the problem...
bq. Make sure Analyzer.close() is called correctly from solr.
Assuming Analyzer's are being closed properly in Solr, then benson's goal
(seems) to be easily solved be making sure the the analyzer's that Solr
constructs on the fly using analysis factories close those factories if they
need it -- A quick skim of the code doesn't give me any confidence that Solr
(specifically i would expect it to be something in IndexSchema) is closing
analyzers properly ... probably because way, way, WAY, back in the day Analyzer
didn't have a close method, and i guess nothing in Solr broke when that method
was added.
So i think the best way forward is to:
# fix whatever needs fixed to make sure IndexSchema closes all of the
Analyzer's it's keeping track of when appropriate to do so.
# do one of the following...
** make AbstractAnalysisFactory implement Closable with a NOOP default and add
a close() method to Solr's TokenizerChain that delegates to all the factories
** add a close() method to Solr's TokenizerChain that does "instanceof
Closable" checks on each factory it's wrapping to know which ones want to be
closed.
thoughts?
> Allow analyzers to be SolrCoreAware
> -----------------------------------
>
> Key: SOLR-4872
> URL: https://issues.apache.org/jira/browse/SOLR-4872
> Project: Solr
> Issue Type: Improvement
> Affects Versions: 4.3
> Reporter: Benson Margulies
>
> I have a need, in an analyzer, to have a shared cache that is cleaned up when
> the core is torn down. Solr rejects analyzer components that are
> SolrCoreAware. Is there some really good reason for this? What harm would
> come from allowing one to register a CloseHook?
--
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: [email protected]
For additional commands, e-mail: [email protected]