[Xapian-devel] patch-Add standard ExpandDecider subclass to restrict to terms with a particular prefix

Olly Betts olly at survex.com
Thu Mar 21 23:00:30 GMT 2013


On Wed, Mar 20, 2013 at 09:12:12AM +0800, jiangwen jiang wrote:
> hi, Olly, Thanks for your suggestion, I have wrote another patch for this

Thanks, it's looking pretty good.

> 1. using stringutils::startswith
> 2. add a feature test in api_nodb.cc(just test prefix function) and
> api_anydb.cc(make sure the decider class works in getESet())

I'd probably just check the cases directly:

    Xapian::ExpandDeciderFilterPrefix decider(prefix);
    TEST(!decider("one"));
    TEST(!decider("t"));
    TEST(!decider(""));
    TEST(!decider("Two"));
    TEST(decider("two"));
    TEST(decider("twitter"));

Carefully putting the testcases in a vector, then iterating that, and
putting the results in a vector which you then have to inspect just
makes the testcase a bit slower and the intent less clear.

I'd also suggest that the prefix itself is an edge case worth checking:

    TEST(decider(prefix));

> 3. add line '+%ignore Xapian::ExpandDeciderFilterPrefix;' in
> xapian-bindings/xapian-headers.i, without this line,there's a make error,
>     I think it is for swig

It would be better to wrap this rather than ignore it.

What's the error?

If it's for Java and C#, then it is probably because for these languages
SWIG generates a source file for each class, and we have a list of the
source files to expect and a check that there aren't any others.  So you
probably just need to add the new source file to csharp/Makefile.am
and java/Makefile.am.

> 4. using git

You might want to look at forking the xapian repo on github, and then
pushing your changes back.  That's how you'd actually work with git on
github, so it's useful to work your way through how to do that.

> In addition, after this work is done, I want to try this project:
> http://trac.xapian.org/wiki/GSoCProjectIdeas#Project:BackendforLuceneformatindexes
> I have some experience in lucence, also have understood the file format and
> read some relative code in xapian

Cool.

Cheers,
    Olly



More information about the Xapian-devel mailing list