lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-3531) Improve CachingWrapperFilter to optionally also cache acceptDocs, if identical to liveDocs
Date Tue, 13 Dec 2011 22:55:30 GMT

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

Uwe Schindler commented on LUCENE-3531:
---------------------------------------

I did some investigation. If you want a complete WeakIdentityHashMap witha all iterators and
so on its heavy to do and you must in all cases also wrap all keys with a WeakReference even
for lookup (unless you implement your completely own HashMap impl). The easy fix here is to
use a wrapper "Reference" object as cache key, that simply has a final field and equals/hashCode
that does the system hashcode. By comparing the wrapper object as key, two wrapper objects
are only equal, if the wrapped objects are identical:

{code:java}
static final class IdentityKeyWrapper<T> {
  public final T key;
  private final int hashCode;

  public IdentityKeyWrapper(T key) {
    this.key = key;
    this.hashCode = System.identityHashCode(key);
  }

  public int hashCode() { return hashCode; }

  public boolean equals(Object o) {
   if (o == this) return true;
   if (o instanceof IdentityKeyWrapper) {
     return ((IdentityKeyWrapper<T>)o).key == this.key;
   }
   return false;
  }

}
{code}

The backside is that you have to wrap the Bits interface even on a lookup, but thats cheap
just like boxing/unboxing (eden space).
                
> Improve CachingWrapperFilter to optionally also cache acceptDocs, if identical to liveDocs
> ------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3531
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3531
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: core/search
>    Affects Versions: 4.0
>            Reporter: Uwe Schindler
>            Assignee: Michael McCandless
>             Fix For: 4.0
>
>         Attachments: LUCENE-3531.patch
>
>
> Spinoff from LUCENE-1536: This issue removed the different cache modes completely and
always applies the acceptDocs using BitsFilteredDocIdSet.wrap(), the cache only contains raw
DocIdSet without any deletions/acceptDocs. For IndexReaders that are seldom reopened, this
might not be as performant as it could be. If the acceptDocs==IR.liveDocs, those DocIdSet
could also be cached with liveDocs applied.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message