sgup432 commented on PR #16657: URL: https://github.com/apache/lucene/pull/16657#issuecomment-5626111858
If we have to replace the query with its canonical representation, I think it has to done at a global level so that each partition uses the shared canonical query. There might be cases(and I have seen many) where users send very large queries and they end up getting cached. To have a map at a global level might introduce some regression but we can a use a `ConcurrentHashMap<Query, Query>`. The harder part is to remove the query from this map when this particular query is removed from all the segments/partitions. This can be done by either introducing a reference counting based mechanism like `ConcurrentHashMap<Query, Tuple<Query, int>>`, so when it goes to 0, we remove it. Or simply rely on GC by doing `ConcurrentHashMap<Query, WeakReferences<Query>>`. I believe from performance perspective both might be same though need to verify. But each has its own tradeoff, reference count based mechanism is determinstic but involves more complexity and `WeakReference` mechanism is more easy to implement but deterministic. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
