Return-Path: Delivered-To: apmail-lucene-pylucene-dev-archive@minotaur.apache.org Received: (qmail 11402 invoked from network); 13 May 2010 05:50:46 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 May 2010 05:50:46 -0000 Received: (qmail 3920 invoked by uid 500); 13 May 2010 05:50:46 -0000 Delivered-To: apmail-lucene-pylucene-dev-archive@lucene.apache.org Received: (qmail 3846 invoked by uid 500); 13 May 2010 05:50:44 -0000 Mailing-List: contact pylucene-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: pylucene-dev@lucene.apache.org Delivered-To: mailing list pylucene-dev@lucene.apache.org Received: (qmail 3837 invoked by uid 99); 13 May 2010 05:50:43 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 May 2010 05:50:43 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [66.159.224.220] (HELO ovaltofu.org) (66.159.224.220) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 May 2010 05:50:37 +0000 Received: from [192.168.0.7] ([192.168.0.7]) (authenticated bits=0) by ovaltofu.org (8.14.3/8.14.4) with ESMTP id o4D5o5JE027141 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 12 May 2010 22:50:10 -0700 (PDT) Date: Wed, 12 May 2010 22:51:52 -0700 (PDT) From: Andi Vajda X-X-Sender: vajda@yuzu.local Reply-To: Andi Vajda To: pylucene-dev@lucene.apache.org Subject: Re: Problems passing PyLucene objects to jcc-wrapped bobo-browse api In-Reply-To: <4BEAD7AF.5020504@semantics.de> Message-ID: References: <4BEAD7AF.5020504@semantics.de> User-Agent: Alpine 2.01 (OSX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Checked: Checked by ClamAV on apache.org On Wed, 12 May 2010, Julian Maibaum wrote: > Christian Heimes, Dirk Rothe, and I have jcc-wrapped bobo-browse > (http://code.google.com/p/bobo-browse/) in order to add faceted search > capabilities to PyLucene. However, the two modules don't play well together, > as wrappers from PyLucene cannot be used in a bobo-browse context and vice > versa. > What is the best way to get classes from two different jcc python extension > modules to interact? I've noticed that when there is overlap in Java classes between two JCC-built extensions, these kinds of errors occur. One can imagine that if the classes have the same name but are not from the same codebase that funny version conflicts might arise, for example. But I haven't looked into exactly what the problem is but a simple workaround is to just create one extension that combines both Lucene and Bobo-browse. Take the JCC invocation for PyLucene from its Makefile and add the things would want from Bobo-browse you want from it and you should have something that works better. Andi.. > > Setup: > X64 Ubuntu 9.10 Python 2.6 Tried both versions: > JCC-2.4.1-py2.6-linux-x86_64.egg compiled with --shared > JCC-2.5.1-py2.6-linux-x86_64.egg compiled with --shared > Tried both versions: > lucene-2.9.1-py2.6-linux-x86_64.egg > lucene-2.9.2-py2.6-linux-x86_64.egg > bobobrowse-2.5.0_rc1-py2.6-linux-x86_64.egg > Both the bobo-browse python extension module and PyLucene are attached to the > main python thread and have been initialized using their respective initVM > methods. > > I have attached the makefile (modified from PyLucene) that was used to build > bobo-browse. > > #---- START CODE ---- > import bobobrowse as bb > import lucene > import os > > CLASSPATH = os.pathsep.join((lucene.CLASSPATH, bb.CLASSPATH) > lucene.initVM(CLASSPATH) > bb.initVM(CLASSPATH) > > typeHandler = bb.MultiValueFacetHandler("type") > placeHandler = bb.MultiValueFacetHandler("id") > > facetHandlers = lucene.JArray('object')(2, bb.FacetHandler) > facetHandlers[0] = typeHandler > facetHandlers[1] = placeHandler > > reader = bb.IndexReader.open('/path/to/my/lucene/index', True) > facetHandlers = bb.Arrays.asList(facetHandlers) > indexReader = bb.BoboIndexReader.getInstance(reader, facetHandlers) > > #---- END CODE ---- > > Expected: > The example code above works - java objects from classes wrapped as part of > the PyLucene module can transparently be used by other python extension > modules such as bobo-browse. > > Experienced: > Throws Errors: > Traceback (most recent call last): > File "./dynamic/vls/search/facets.py", line 115, in > test() > File "./dynamic/smc/jcc/__init__.py", line 52, in wrapper > return func(*args, **kwargs) > File "./dynamic/vls/search/facets.py", line 57, in test > facetHandlers = lucene.JArray('object')(2, bb.FacetHandler) > ValueError: > > and > > bobobrowse.InvalidArgsError: (, 'getInstance', > (, > com.browseengine.bobo.facets.impl.MultiValueFacetHandler@2980f96c]>)) > > respectively. > > The Errors can be avoided by changing the corresponding lines in the example > above to: > facetHandlers = bb.JArray('object')(2, bb.FacetHandler) > reader = bb.IndexReader.open('/path/to/my/lucene/index', True) > > However, this only works because lucene's IndexReader is referenced by > bobo-browse and has therefore been wrapped at build-time. At later stages > other lucene classes are needed to work with bobobrowse that no wrappers have > been built for (e.g. QueryParser). I understand that jcc can be forced to > built and include wrappers for e.g. org.apache.lucene.queryParser.QueryParser > that are then accessible for use with classes from the bobo-browse module as > e.g 'bobobrowse.QueryParser'. The most simple solution is calling jcc with an > additional --jar lucene.jar parameter - in effect leading to lucene being > installed twice: First self-contained PyLucene module and, second, as part of > bobo-browse in the flat bobo-browse module namespace. This is not quite > desirable: > Since > bb.IndexReader.class_ == lucene.IndexReader.class_ > --> class org.apache.lucene.index.IndexReader, anyways, it would arguably be > more intuitive to be able to use the available wrappers in the context of > other jcc modules even if they have not specifically been forced into that > other module. Is there any way to obtain the desired behavior? > > > Thank you very much and all the best, > > Julian Maibaum > > > j.maibaum(at)semantics.de > smantics GmbH > http://www.semantics.de >