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

Hoss Man commented on SOLR-2783:
--------------------------------

bq. It would be nice if DocSet (the parent interface) can be made Serializable

In general I feel like this would be a bad idea.

DocSets are inherently transient - they contain information that is tied not 
only to a specific index, but a specific commit point because the docIds in the 
set are invalid if the index is merged or appended to in anyway.  Marking them 
as Serializable could easily mislead people into thinking that _in general_ the 
type of serialization you are doing is "safe"

In your _specific case_, you might be constraining the usage of your cache, and 
the usage of this serialization to ensure that you never attempt to use a 
deserialized DocSet in a way that no longer makes sense (ie: against a diff 
version of the index) but i really don't think we want to encourage that in the 
general case.

---

To work around this w/o relying on the deprecated method, you can always check 
the implementation of the DocSet and call BitDocSet.getBits() or 
DocSet.iterator() as the case may be.
                
> Please make DocSet extend Serializable
> --------------------------------------
>
>                 Key: SOLR-2783
>                 URL: https://issues.apache.org/jira/browse/SOLR-2783
>             Project: Solr
>          Issue Type: Wish
>         Environment: Any.
>            Reporter: Sujit Pal
>            Priority: Minor
>
> We have built a custom EHCache backed implementation of SolrCache that allows 
> us to spill over the cache to disk and have it persistent across Solr 
> restarts. To allow disk spillover we need the key and value of the cache to 
> be Serializable. So our SolrCache implementation signature is like this:
> {code}
> public class EhCacheSolrCache implements SolrCache<Serializable,Serializable> 
> {
> ...
> }
> {code}
> One of the things we are caching are DocSets (specifically BitDocSets). 
> Currently we are wrapping it into a Serializable class of our own:
> {code}
> public class SerializableBitDocSet extends BitDocSet implements Serializable {
>   private static final long serialVersionUID = 3723685897599896159L;
>   public SerializableBitDocSet() {
>     super();
>   }
>   
>   public SerializableBitDocSet(OpenBitSet obs) {
>     super(obs);
>   }
> {code}
> and when getting or putting into the cache, we convert to the Serializable 
> version using the deprecated method getBits().
> {code}
> SerializableBitDocSet docset = new 
> SerializableBitDocSet(newSearcher.getDocSet(q).getBits());
> newSearcher.getCache(CACHED_FACETS_BITSETS_CACHENAME).put(facetQuery, docset);
> {code}
> On the get, since a SerializableBitDocSet is a BitDocSet there is no extra 
> work.
> Two issues:
> 1) we are using a deprecated getBits() call to make the conversion - this is 
> likely to disappear in a later version.
> 2) the approach is hacky, since we have to potentially subclass other bitset 
> like structures to make them Serializable as well.
> It would be nice if DocSet (the parent interface) can be made Serializable. 
> This would allow Solr users to use this as a cache value for disk-persistent 
> caches without any hackery.

--
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-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to