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

Christian Kohlschütter edited comment on LUCENE-2135 at 12/8/09 8:05 PM:
-------------------------------------------------------------------------

bq. If I'm reading your patch right, to add something as a user to 
DirectoryReader+SegmentReader, I have to extend SegmentReaderIndexCache, 
IndexCache, then extend SegmentReader and DirectoryReader, and override all 
methods in DirectoryReader that create SegmentReader.

No, the functionality you intend to have is just not there at the moment. But 
it could be added directly to IndexCache (and thus, to all subclasses of 
IndexCache automatically).

bq. My aim is to be able to bind stuff to readers without overriding them, 
delegating, or touching in any manner except providing certain factories on 
creation.

We could add getProperty/setProperty methods to IndexCache. You could then 
bind/get arbitrary objects as follows:

IndexReader ir = // somehow create your new reader
IndexCache cache = ir.getIndexCache();
Object someObject = cache.getProperty(someKey);
cache.setProperty("org.example.someCoolProperty", anotherObject);

(Personally, I prefer standardized string keys to avoid collisions, just like 
in the Servlet API, for example)

Again, this is not yet implemented, but could be done easily, without affecting 
any existing IndexReader or the other changes on FieldCache etc.


      was (Author: c...@newsclub.de):
    bq. If I'm reading your patch right, to add something as a user to 
DirectoryReader+SegmentReader, I have to extend SegmentReaderIndexCache, 
IndexCache, then extend SegmentReader and DirectoryReader, and override all 
methods in DirectoryReader that create SegmentReader.

No, the functionality you intend to have is just not there at the moment. But 
it could be added directly to IndexCache (and thus, to all subclasses of 
IndexCache automatically).

bq. My aim is to be able to bind stuff to readers without overriding them, 
delegating, or touching in any manner except providing certain factories on 
creation.

We could add getProperty/setProperty methods to IndexCache. You could then 
bind/get arbitrary objects as follows:

IndexReader ir = // somehow create your new reader
IndexCache cache = ir.getIndexCache();
Object someObject = cache.getProperty(whatEverKey);
cache.setProperty("org.example.someCoolProperty", anotherObject);

(Personally, I prefer standardized string keys to avoid collisions, just like 
in the Servlet API, for example)

Again, this is not yet implemented, but could be done easily, without affecting 
any existing IndexReader or the other changes on FieldCache etc.

  
> IndexReader.close should forcefully evict entries from FieldCache
> -----------------------------------------------------------------
>
>                 Key: LUCENE-2135
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2135
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>             Fix For: 3.1
>
>         Attachments: LUCENE-2135.patch, LUCENE-2135.patch, LUCENE-2135.patch
>
>
> Spinoff of java-user thread "heap memory issues when sorting by a string 
> field".
> We rely on WeakHashMap to hold our FieldCache, keyed by reader.  But this 
> lacks immediacy on releasing the reference, after a reader is closed.
> WeakHashMap can't free the key until the reader is no longer referenced by 
> the app. And, apparently, WeakHashMap has a further impl detail that requires 
> invoking one of its methods for it to notice that a key has just become only 
> weakly reachable.
> To fix this, I think on IR.close we should evict entries from the FieldCache, 
> as long as the sub-readers are truly closed (refCount dropped to 0).

-- 
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