On Fri, 22 Sep 2006, Yura Smolsky wrote:
I want to add new class to PyLucene. It is PrefixFilter. Its from SOLR project. http://svn.apache.org/viewvc/incubator/solr/trunk/src/java/org/apache/solr/search/PrefixFilter.java?revision=423263&view=markup Where should I put this file and what files of PyLucene I should change to make this call available to use from python? I am asking cos I want to be able adding more classes myself without bothering you.
It's best to take a look at how other various parts of PyLucene are put together. PyLucene is Java Lucene core + a bunch of Java Lucene contrib packages put together and wrapped. Each package core and contrib is first compiled from .java to .jar using ant a regular JDK. Here are steps to follow:
1. The class you want to wrap is not part of either the core or a contrib package so you have to first integrate it into one. You could cheat and add it into Lucene's search package, changing solr into lucene in the package statement. That way Java Lucene's ant would just pick it up and add it to lucene.jar. You could also not change the package name and create a patch for Lucene's ant file (build.xml) so that this solr class is built and integrated into lucene.jar. Once it's in lucene.jar, you're done with the .java -> .jar step. 2. Edit lucene.cpp and add an #import statement for the header that would be produced by gcjh when lucene.jar was built (line 445 of Makefile). See what is done for RangeFilter. 3. Following the pattern used for all other classes, pick an example like RangeFilter and first add the declarations for the methods and the type for PrefixFilter. It's best to copy/paste the RangeFilter stuff, change 'range' into 'prefix' and proceed to fixup the rest to fit what you want from PrefixFilter. The j_prefixfilter_init method is the constructor. If you need no other methods from PrefixFilter leave the j_prefixfilter_methods array empty. The 'bits' method wrapper is inherited from j_filter since PrefixFilter extends Filter (as declared with DECLARE_TYPE, a macro defined in macros.h). 4. Following RangeFilter again, look for the next part with RangeFilter that actually implements the code for the wrappers, further down in lucene.cpp. Again copy/paste/fixup what you need to fit PrefixFilter. parseArgs is a macro that expands into _parseArgs, a function defined in functions.cpp. See its code to understand the meaning of the bytes in the second argument. 5. Towards the bottom of lucene.cpp, add a statement to install the new type you created. Again, follow what is done for RangeFilter. Andi.. _______________________________________________ pylucene-dev mailing list [email protected] http://lists.osafoundation.org/mailman/listinfo/pylucene-dev
