[pylucene-dev] can't override QueryParser.parse()

Andi Vajda vajda at osafoundation.org
Tue Nov 13 22:14:07 PST 2007


On Tue, 13 Nov 2007, Andi Vajda wrote:

> On Tue, 13 Nov 2007, Andi Vajda wrote:
>
>> On Tue, 13 Nov 2007, Bill Janssen wrote:
>> 
>>> It crashes for me, too, when I run it with an unmodified JCC.
>>> 
>>> To get the error I reported, I use a much larger codebase.  But I
>>> think it's the same problem -- the 'value' field isn't of the type
>>> reported by the 'exc' field.  And it's crashing in the same place,
>>> in the call to the Java implementation of getBooleanQuery.
>> 
>> It's crashing because your code example is a little screwy. It's passing a 
>> MultiFieldQueryParser instance to a QueryParser wrapper. The C++ methods on 
>> the C++/JNI wrapper are not virtual and hence this is not going to do what 
>> you think. The fact that getBooleanQuery() is even called makes no sense if 
>> what you're invoking is parse().
>
> Strike that, I was confused by gdb output. Debugging a python executable with 
> gdb on leopard, using the system python, is a little problematic. I'm 
> building my own now...

I found why it crashed. There was a bug in the code generating the call to a 
"super" method. The JNI method id used better come from a class that actually 
declares a method to invoke. The problem here was that MultiFieldQueryParser 
doesn't actually declare getBooleanQuery(), it only inherits, while 
QueryParser does declare it. So MultiFieldQueryParser didn't have an entry for 
that method in the method table I generate for it. Yet it was also inheriting 
the constant for the method id and garbage was invoked.

I fixed the bug on the trunk and the sample code you sent earlier now runs 
fine. I don't know if this fixes the error you originally reported but a bug 
it revealed still.

Thanks !  (and apologies for blaming your example code :)

Andi..


More information about the pylucene-dev mailing list