You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Bob Carpenter <ca...@alias-i.com> on 2006/06/13 21:14:20 UTC
Refactored FuzzyTermEnum
I refactored the org.apache.lucene.search.FuzzyTermEnum
edit distance implementation. It now only uses a single
pair of arrays, and those never get resized. That required
turning the order of text/target around in the loops. You'll
see that with the pair of arrays method, they get re-used
hand-over-hand, and are assigned to local variables in the
tight loops.
I removed the calculation of min distance and replaced
it with a boolean -- the min wasn't needed, only the test vs.
the max. I also flipped some variables around so there's
one less addition in the very inner loop and the arrays are
now looping in the ordinary way (starting at 0 with a < comparison).
I also commented out the redundant definition of the public close()
[which just called super.close() and had none of its own doc.]
I also just compute the max distance each time rather than
fiddling with an array -- it's just a little arithmetic done once
per term, but that could be put back.
I also rewrote min(int,int,int) to get rid of intermediate
assignments. Is there a lib for this kind of thing?
An intermediate refactoring that does the hand-over-hand
with the existing array and resizing strategy is in
FuzzyTermEnum.intermed.java.
I ran the unit tests as follows on both versions (my hat's off to the
build.xml author(s) -- this all just worked out of the box and was
really easy to follow the first through):
C:\java\lucene-2.0.0>ant -Djunit.includes="" -Dtestcase=TestFuzzyQuery test
Buildfile: build.xml
javacc-uptodate-check:
javacc-notice:
init:
common.compile-core:
[javac] Compiling 1 source file to
C:\java\lucene-2.0.0\build\classes\java
compile-core:
compile-demo:
common.compile-test:
compile-test:
test:
[junit] Testsuite: org.apache.lucene.search.TestFuzzyQuery
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.453 sec
BUILD SUCCESSFUL
Total time: 2 seconds
Does anyone have regression/performance test harnesses?
The unit tests were pretty minimal (which is a good thing!).
It'd be nice to test the min impl (ternary vs. if/then)
and the assumption about not allocating an
array of max distances. All told, the refactored version
should be a modest speed improvement, mainly from
unfolding the arrays so they're local one-dimensional refs.
I don't know what the protocol is for one-off contributions.
I'm happy with the Apache license, so that shouldn't
be a problem. I also don't know whether you use tabs
or spaces -- I untabified the final version and used your
two-space format in emacs.
- Bob Carpenter
Re: Refactored FuzzyTermEnum
Posted by Chris Hostetter <ho...@fucit.org>.
: I don't know what the protocol is for one-off contributions.
I'm not sure what you mean by a "one-off contribution" but the process for
submiting changes/improvements/additions was recenlty wiki-ized...
http://wiki.apache.org/jakarta-lucene/HowToContribute
(Incidently, please feel free to share any comments/questions you have
about hte process that you feel the wiki doesn't address well)
: I'm happy with the Apache license, so that shouldn't
When you go to attach your patch to a Jira issue, there will be an option
to make it explicit that you "Grant license to ASF for inclusion in ASF
works"
: be a problem. I also don't know whether you use tabs
: or spaces -- I untabified the final version and used your
: two-space format in emacs.
the majority of the lucene code base seems to be no tabs, 2 space
indenting -- but the golden rule is don't change the formating of any code
(even code that is hideously formatted) as part of a patch that changes
functionality. Formatting changes should be in their own patches/commits
so it's clear that's all that's changed.
One comment i have about your new submission is that it's not clear to me
what the purpose of your changes are -- please don't feel that's a
criticism, i just don't use FuzzyQueries myself, so maybe it's obvious to
others, but when opening the Jira issue please make sure the problem
statement that motivated you to make these changes is explained. If it
was to fix a bug, please include a test case that fails without this
change; if it was to improve performance, please include some sample code
that demonstrates the performance improvement; if it was to add new
functionality, please include a test that demonstrates the new
functionality working.
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: Refactored FuzzyTermEnum
Posted by karl wettin <ka...@snigel.net>.
On Thu, 2006-06-15 at 11:42 +0200, karl wettin wrote:
>
> 2. Standard RAMDirectory:
Oups, I got the headers wrong here. Again:
With your fixes:
1000 fuzzy~0.1, 121 per min.
1000 fuzzy~0.2, 190 per min.
1000 fuzzy~0.3, 342 per min.
1000 fuzzy~0.4, 456 per min.
1000 fuzzy~0.5, 578 per min.
1000 fuzzy~0.6, 632 per min.
1000 fuzzy~0.7, 645 per min.
1000 fuzzy~0.8, 679 per min.
1000 fuzzy~0.9, 696 per min.
Old implementation:
1000 fuzzy~0.1, 117 per min.
1000 fuzzy~0.2, 185 per min.
1000 fuzzy~0.3, 329 per min.
1000 fuzzy~0.4, 425 per min.
1000 fuzzy~0.5, 585 per min.
1000 fuzzy~0.6, 612 per min.
1000 fuzzy~0.7, 653 per min.
1000 fuzzy~0.8, 615 per min.
1000 fuzzy~0.9, 671 per min.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: Refactored FuzzyTermEnum
Posted by karl wettin <ka...@snigel.net>.
On Tue, 2006-06-13 at 15:14 -0400, Bob Carpenter wrote:
> I refactored the org.apache.lucene.search.FuzzyTermEnum
Nice!
> Does anyone have regression/performance test harnesses?
I have a quite unscientific test I ran. 500 documents in corpus. One
index reader. A new Index searcher for each query iteration. 100
iterations. Each iteration contains 10 queries:
is.search(new FuzzyQuery(new Term(field, "hare"), d));
is.search(new FuzzyQuery(new Term(field, "nimi"), d));
is.search(new FuzzyQuery(new Term(field, "miama"), d));
is.search(new FuzzyQuery(new Term(field, "mamma"), d));
is.search(new FuzzyQuery(new Term(field, "sumatra"), d));
is.search(new FuzzyQuery(new Term(field, "buch"), d));
is.search(new FuzzyQuery(new Term(field, "busch"), d));
is.search(new FuzzyQuery(new Term(field, "hejples"), d));
is.search(new FuzzyQuery(new Term(field, "sveden"), d));
is.search(new FuzzyQuery(new Term(field, "cwedish"), d));
I do not gather the Documents from the index.
1. On my issue 550-index
Old implementation:
1000 fuzzy~0.1, 633 per min.
1000 fuzzy~0.2, 784 per min.
1000 fuzzy~0.3, 1236 per min.
1000 fuzzy~0.4, 1462 per min.
1000 fuzzy~0.5, 1917 per min.
1000 fuzzy~0.6, 2574 per min.
1000 fuzzy~0.7, 2750 per min.
1000 fuzzy~0.8, 3375 per min.
1000 fuzzy~0.9, 3524 per min.
With your fixes:
1000 fuzzy~0.1, 603 per min.
1000 fuzzy~0.2, 886 per min.
1000 fuzzy~0.3, 1403 per min.
1000 fuzzy~0.4, 1681 per min.
1000 fuzzy~0.5, 2165 per min.
1000 fuzzy~0.6, 2961 per min.
1000 fuzzy~0.7, 3137 per min.
1000 fuzzy~0.8, 3948 per min.
1000 fuzzy~0.9, 4594 per min.
2. Standard RAMDirectory:
Old implementation:
1000 fuzzy~0.1, 121 per min.
1000 fuzzy~0.2, 190 per min.
1000 fuzzy~0.3, 342 per min.
1000 fuzzy~0.4, 456 per min.
1000 fuzzy~0.5, 578 per min.
1000 fuzzy~0.6, 632 per min.
1000 fuzzy~0.7, 645 per min.
1000 fuzzy~0.8, 679 per min.
1000 fuzzy~0.9, 696 per min.
With your fixes:
1000 fuzzy~0.1, 117 per min.
1000 fuzzy~0.2, 185 per min.
1000 fuzzy~0.3, 329 per min.
1000 fuzzy~0.4, 425 per min.
1000 fuzzy~0.5, 585 per min.
1000 fuzzy~0.6, 612 per min.
1000 fuzzy~0.7, 653 per min.
1000 fuzzy~0.8, 615 per min.
1000 fuzzy~0.9, 671 per min.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: Refactored FuzzyTermEnum
Posted by Otis Gospodnetic <ot...@yahoo.com>.
I'm still waiting for my employer to send in the CCLA. :(
But I've got a cool name for this thing - "lube" - contrib/lube.
Otis
----- Original Message ----
From: Marvin Humphrey <ma...@rectangular.com>
To: java-dev@lucene.apache.org
Sent: Wednesday, June 14, 2006 3:51:52 AM
Subject: Re: Refactored FuzzyTermEnum
On Jun 13, 2006, at 12:14 PM, Bob Carpenter wrote:
> Does anyone have regression/performance test harnesses?
There's been talk of formalizing a benchmarker suite. Andrzej wrote
something a while ago; I don't know if it would be appropriate for this.
The benchmarker I wrote is indexing only, unfortunately.
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: Refactored FuzzyTermEnum
Posted by Marvin Humphrey <ma...@rectangular.com>.
On Jun 13, 2006, at 12:14 PM, Bob Carpenter wrote:
> Does anyone have regression/performance test harnesses?
There's been talk of formalizing a benchmarker suite. Andrzej wrote
something a while ago; I don't know if it would be appropriate for this.
The benchmarker I wrote is indexing only, unfortunately.
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org