You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by lu...@fantasymail.de on 2003/06/15 22:18:19 UTC

HitCollector not serializable (Bug?)

Hi,

i tried Lucene 1.3 RC1.

There seems to be a bug in
org.apache.lucene.search.RemoteSearchable.search(). 

Here is my code:
   Searchable searcher =
      (Searchable) Naming.lookup(args[0]);
   Analyzer analyzer = new StandardAnalyzer();
   Query query = QueryParser.parse("term", "content", analyzer);
   HitCollector hc = new HitCollector()
   {
      public void collect(int doc, float score)
      {
           //bits.set(doc);
      }
   };

   searcher.search(query, (DateFilter)null, hc);

I'm getting the following exception:

java.rmi.MarshalException: error marshalling arguments; nested exception
 is: java.io.NotSerializableException:
 com.entwickler.lucenebuch.remote.SearchClient$1
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
         at org.apache.lucene.search.RemoteSearchable_Stub.search(Unknown
 Source)
         at
 com.entwickler.lucenebuch.remote.SearchClient.main(SearchClient.java:47)
 Caused by: java.io.NotSerializableException:
 com.entwickler.lucenebuch.remote.SearchClient$1
         at
 java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
         at
 java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278) at
 sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:265) at
 sun.rmi.server.UnicastRef.invoke(UnicastRef.java:124)


This happens because org.apache.lucene.search.HitCollector is not
serializable.


Greetings
Manfred

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!


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


Re: HitCollector not serializable (Bug?)

Posted by Manfred Hardt <lu...@fantasymail.de>.
There should be a comment about this "best practice" in the API/Javadocs.

Manfred

> The HitCollector-based search API is not meant to work remotely.  To do
> so would involve an RPC-callback for every non-zero score, which would
> be extremely expensive.  Also, just making HitCollector serializable
> would not be sufficient.  You'd also need to pass in a HitCollector
> implementation that subclasses UnicastRemoteObject, so that the
> callbacks can return to the original VM.
>
> So, if you can, it's considerably simpler and more efficient to use
> TopDocs-based search when you're working remotely.
>
> Doug
>
> lucene@fantasymail.de wrote:
> > Hi,
> >
> > i tried Lucene 1.3 RC1.
> >
> > There seems to be a bug in
> > org.apache.lucene.search.RemoteSearchable.search().
> >
> > Here is my code:
> >    Searchable searcher =
> >       (Searchable) Naming.lookup(args[0]);
> >    Analyzer analyzer = new StandardAnalyzer();
> >    Query query = QueryParser.parse("term", "content", analyzer);
> >    HitCollector hc = new HitCollector()
> >    {
> >       public void collect(int doc, float score)
> >       {
> >            //bits.set(doc);
> >       }
> >    };
> >
> >    searcher.search(query, (DateFilter)null, hc);
> >
> > I'm getting the following exception:
> >
> > java.rmi.MarshalException: error marshalling arguments; nested exception
> >  is: java.io.NotSerializableException:
> >  com.entwickler.lucenebuch.remote.SearchClient$1
> >          at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
> >          at org.apache.lucene.search.RemoteSearchable_Stub.search(Unknown
> >  Source)
> >          at
> >  com.entwickler.lucenebuch.remote.SearchClient.main(SearchClient.java:47)
> >  Caused by: java.io.NotSerializableException:
> >  com.entwickler.lucenebuch.remote.SearchClient$1
> >          at
> >  java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
> >          at
> >  java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278) at
> >  sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:265) at
> >  sun.rmi.server.UnicastRef.invoke(UnicastRef.java:124)
> >
> >
> > This happens because org.apache.lucene.search.HitCollector is not
> > serializable.
> >
> >
> > Greetings
> > Manfred
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


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


Re: HitCollector not serializable (Bug?)

Posted by Doug Cutting <cu...@lucene.com>.
The HitCollector-based search API is not meant to work remotely.  To do 
so would involve an RPC-callback for every non-zero score, which would 
be extremely expensive.  Also, just making HitCollector serializable 
would not be sufficient.  You'd also need to pass in a HitCollector 
implementation that subclasses UnicastRemoteObject, so that the 
callbacks can return to the original VM.

So, if you can, it's considerably simpler and more efficient to use 
TopDocs-based search when you're working remotely.

Doug

lucene@fantasymail.de wrote:
> Hi,
> 
> i tried Lucene 1.3 RC1.
> 
> There seems to be a bug in
> org.apache.lucene.search.RemoteSearchable.search(). 
> 
> Here is my code:
>    Searchable searcher =
>       (Searchable) Naming.lookup(args[0]);
>    Analyzer analyzer = new StandardAnalyzer();
>    Query query = QueryParser.parse("term", "content", analyzer);
>    HitCollector hc = new HitCollector()
>    {
>       public void collect(int doc, float score)
>       {
>            //bits.set(doc);
>       }
>    };
> 
>    searcher.search(query, (DateFilter)null, hc);
> 
> I'm getting the following exception:
> 
> java.rmi.MarshalException: error marshalling arguments; nested exception
>  is: java.io.NotSerializableException:
>  com.entwickler.lucenebuch.remote.SearchClient$1
>          at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:129)
>          at org.apache.lucene.search.RemoteSearchable_Stub.search(Unknown
>  Source)
>          at
>  com.entwickler.lucenebuch.remote.SearchClient.main(SearchClient.java:47)
>  Caused by: java.io.NotSerializableException:
>  com.entwickler.lucenebuch.remote.SearchClient$1
>          at
>  java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
>          at
>  java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278) at
>  sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:265) at
>  sun.rmi.server.UnicastRef.invoke(UnicastRef.java:124)
> 
> 
> This happens because org.apache.lucene.search.HitCollector is not
> serializable.
> 
> 
> Greetings
> Manfred
> 


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