[ 
https://issues.apache.org/jira/browse/LUCENE-2154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12831489#action_12831489
 ] 

Uwe Schindler commented on LUCENE-2154:
---------------------------------------

The problem is the following:

Attributes are not to be retrieved on every call to next(), they are get/added 
after construction. If you have a consumer of your MultiEnum, it calls 
attributes().getAttribute exactly one time before start to enumerate 
tokens/positions/whatever. If your proposed MultiAttributeSource would return 
the attribute of the first sub-enum, the consumer would stay with this 
attribute instance forever. If the MultiEnum then changes to another sub-enum, 
the consumer would not see the new attribute.

Because of that the right way is not to have a MultiAttributeSource. What you 
need are proxy attributes. The Attributes itsself must be proxies, delegating 
the call to the current enum's corresponding attribute. The same was done in 
Lucene 2.9 to emulate the backwards compatibility for TokenStreams. The proxy 
was TokenWrapper. These ProxyAttributes would look exactly like this 
TokenWrapper impl class.

> 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

Reply via email to