[ https://issues.apache.org/jira/browse/LUCENE-2154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12789571#action_12789571 ]
Uwe Schindler commented on LUCENE-2154: --------------------------------------- I have an idea, but please don't hurt me, it uses reflection. What is needed: Like in the TokenStream BW layer, we had a class called TokenWrapper that implemented all interfaces for basic Tokens but was a wrapper around a Token. This Token was exchangeable. The idea for this case is: - DirReader/MultiReader cannot share thesame AttributeSource at all, because e.g. if th DirReader's enum first tries to call next() on on the first enum, the attributes are overriden. If DirrReader then instead also calls next() on the second sub-enum, the data of the first is overriden and cannot be restaured. The idea is now, to have the same Wrapper like TokenWrapper, where the interface impls behind can be exchanged, so the Dir/MultiReader enum just points its own attribute wrapper to the correct attributeset behind. - The problem are custom attributes or e.g. BoostAttribute. Nobody knows what attributes may be generated, so it is impossible to create an wrapper for all. But Java has a solution: [http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Proxy.html]. This class implements a proxy stub for a set of interfaces (you just pass all interfaces needed) andthe returned object can be added to the local DirReader/MultiReaders enum attsource using addAttribute(). You only have to point to a implementation class that gets the Method reference and calls the corresponding method in the current interface (Like the actual Token in TokenWrapper) of the sub-enum. Sounds like ugly magic, but I have to test how fast it is and how it exactly works with AttributeSource. But the proxy instances could be cached like the TokenStream BW compatibility. > Need a clean way for Dir/MultiReader to "merge" the AttributeSources of the > sub-readers > --------------------------------------------------------------------------------------- > > Key: LUCENE-2154 > URL: https://issues.apache.org/jira/browse/LUCENE-2154 > Project: Lucene - Java > Issue Type: Bug > Components: Index > Affects Versions: Flex Branch > Reporter: Michael McCandless > Fix For: Flex Branch > > > The flex API allows extensibility at the Fields/Terms/Docs/PositionsEnum > levels, for a codec to set custom attrs. > But, it's currently broken for Dir/MultiReader, which must somehow share > attrs across all the sub-readers. Somehow we must make a single attr source, > and tell each sub-reader's enum to use that instead of creating its own. > Hopefully Uwe can work some magic here :) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org