Conversation

vanboom

The class level map using @@__types messes up the autoloading when STI classes are present. The Registry.all.detect lookup should be very fast so this seems to be a good trade off to fix the old STI auto load issue that was reported in #838 and closed by the stalebot.

Related PR #888 was also closed with a statement that STI support is deprecated and removed from the gem. It is my opinion that this PR and #888 is a fix related to Rails autoloading and has nothing to do with STI support.

Please consider this PR to close #848 for good. Thanks!

…nt, fix index name to klass lookup methodology
@cla-checker-serviceCLA Checker Service

💚 CLA has been signed


key = "#{hit[:_index]}::#{hit[:_type]}" if hit[:_type] && hit[:_type] != '_doc'
key = hit[:_index] unless key

@@__types[key] ||= begin
Copy link
Author

@vanboom vanboom Nov 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put Benchmark.measure around this code and contrary to my expectations, the original hash method was WAY. We will have to re-think this change, maybe the method of storing the class->index_name mapping can be improved to mitigate #838 with performance.
image

NOTE: my models use a Proc for index_name in a multi-tenant application so we are attempting to use an apartment qualified index name. Seems the Proc based index_name is causing the performance hit.

Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Invalid single-table inheritance type: SubClass is not a subclass of Class