Return-Path: Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: (qmail 48089 invoked from network); 1 Mar 2005 00:37:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 1 Mar 2005 00:37:24 -0000 Received: (qmail 61094 invoked by uid 500); 1 Mar 2005 00:37:23 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 61081 invoked by uid 500); 1 Mar 2005 00:37:23 -0000 Delivered-To: apmail-incubator-lucene4c-cvs@incubator.apache.org Received: (qmail 61076 invoked by uid 99); 1 Mar 2005 00:37:23 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 28 Feb 2005 16:37:23 -0800 Received: (qmail 48085 invoked by uid 65534); 1 Mar 2005 00:37:22 -0000 Message-ID: <20050301003722.48084.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Tue, 01 Mar 2005 00:37:22 -0000 Subject: svn commit: r155723 - in incubator/lucene4c/trunk: src/search/scorer.c test/search/scorer_test.c To: lucene4c-cvs@incubator.apache.org From: rooneg@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: rooneg Date: Mon Feb 28 16:37:21 2005 New Revision: 155723 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D155723 Log: Finish fixing up boolean queries containing should occurances. If we have should queries then we can't just bail the first time one of the scorers returns EOF, if it was a should scorer then we remove that scorer from our set of candidates and move on, until we run out of should scorers, at which point we're done. * src/search/scorer.c (boolean_search_scorer_t): add should_left member to track the number of should scorers left. (pick_scorer): deal with the fact that should scorers can be NULL. (boolean_scorer_find_doc): handle EOF errors more carefully, deal with the fact that should scorers can be NULL. (lcn_boolean_scorer_create): initialize bsb->should_left. * test/search/scorer_test.c (test_boolean_scorer): remove out of date comment. Modified: incubator/lucene4c/trunk/src/search/scorer.c incubator/lucene4c/trunk/test/search/scorer_test.c Modified: incubator/lucene4c/trunk/src/search/scorer.c URL: http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/search/scor= er.c?view=3Ddiff&r1=3D155722&r2=3D155723 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/lucene4c/trunk/src/search/scorer.c (original) +++ incubator/lucene4c/trunk/src/search/scorer.c Mon Feb 28 16:37:21 2005 @@ -65,6 +65,9 @@ apr_array_header_t *should; apr_array_header_t *must_not; =20 + /* the number of should scorers we have left in the array */ + int should_left; + /* the scorer we used last time through boolean_scorer_find_doc's main * loop to get our initial document for comparisons. */ lcn_scorer_t *last_scorer; @@ -102,6 +105,8 @@ lcn_scorer_t *scorer =3D APR_ARRAY_IDX (bsb->should, i, lcn_scorer_t *); + if (! scorer) + continue; =20 apr_uint32_t doc =3D lcn_scorer_doc (scorer); =20 @@ -139,7 +144,39 @@ /* if we have a last scorer (i.e. we already came through this * function already) move it along to the next document. */ if (bsb->last_scorer !=3D NULL) - LCN_ERR (lcn_scorer_next (bsb->last_scorer)); + { + lcn_error_t *err =3D lcn_scorer_next (bsb->last_scorer); + + /* If we get an EOF we need to be careful... If there are any + * should scorers then we have to check to see if this was one + * of them, and if it was we don't bail out, instead we remove + * it from the array and reduce our count, if we hit zero then + * we're done with all the shoulds and that means we are done, + * otherwise clear the error and continue looping. */ + + if (err && err->apr_err =3D=3D APR_EOF && bsb->should_left > 0) + { + lcn_boolean_t its_a_should =3D FALSE; + + for (i =3D 0; i < bsb->should->nelts; ++i) + { + if (APR_ARRAY_IDX (bsb->should, i, lcn_scorer_t *) + =3D=3D bsb->last_scorer) + { + APR_ARRAY_IDX (bsb->should, i, lcn_scorer_t *) =3D N= ULL; + bsb->should_left--; + its_a_should =3D TRUE; + } + } + + if (bsb->should_left =3D=3D 0 || its_a_should =3D=3D FALSE) + return err; + else + lcn_error_clear (err); + } + else if (err) + return err; + } =20 /* when we add support for should scorers the selection of this * scorer becomes more complex, but for now we can just pick an @@ -158,6 +195,8 @@ lcn_scorer_t *should_scorer =3D APR_ARRAY_IDX (bsb->should, i, lcn_scorer_t *); + if (! should_scorer) + continue; =20 apr_uint32_t otherdoc =3D lcn_scorer_doc (should_scorer); =20 @@ -267,6 +306,8 @@ sizeof (lcn_scorer_t *)); =20 LCN_ERR (fill_scorers_array (should, bsb->should, index, pool)); + + bsb->should_left =3D should->nelts; =20 bsb->must_not =3D apr_array_make (pool, must_not->nelts, Modified: incubator/lucene4c/trunk/test/search/scorer_test.c URL: http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/test/search/sco= rer_test.c?view=3Ddiff&r1=3D155722&r2=3D155723 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/lucene4c/trunk/test/search/scorer_test.c (original) +++ incubator/lucene4c/trunk/test/search/scorer_test.c Mon Feb 28 16:37:21 = 2005 @@ -174,7 +174,6 @@ =20 ABTS_INT_EQUAL (tc, APR_EOF, err->apr_err); =20 - /* expected to fail for now, should queries aren't quite working yet */ ABTS_INT_EQUAL (tc, 113, count); =20 apr_pool_clear (p);