Ticket #476: andmaybe_skip_doc.patch

File andmaybe_skip_doc.patch, 4.2 KB (added by Richard Boulton, 14 years ago)

Patch containing potential fix

  • matcher/andmaybepostlist.h

     
    108108            rmax = r->get_maxweight();
    109109        }
    110110
     111        /** Synchronise the RHS to the LHS after construction.
     112         *  Used after constructing from a decomposing OrPostList
     113         */
     114        PostList * sync_rhs(Xapian::weight w_min);
     115
    111116        /** get_wdf() for ANDMAYBE postlists returns the sum of the wdfs of the
    112117         *  sub postlists which are at the current document - this is desirable
    113118         *  when the ANDMAYBE is part of a synonym.
  • matcher/orpostlist.cc

     
    5858                                       matcher);
    5959            } else {
    6060                LOGLINE(MATCH, "OR -> AND MAYBE (1)");
    61                 ret = new AndMaybePostList(r, l, matcher, dbsize, rhead, lhead);
    62                 next_handling_prune(ret, w_min, matcher);
     61                AndMaybePostList * ret2 =
     62                        new AndMaybePostList(r, l, matcher, dbsize, rhead, lhead);
     63                ret = ret2;
     64                // Advance the AndMaybePostList unless the old RHS postlist was
     65                // already ahead of the current docid.
     66                if ((rhead <= lhead)) {
     67                    next_handling_prune(ret, w_min, matcher);
     68                } else {
     69                    handle_prune(ret, ret2->sync_rhs(w_min));
     70                }
    6371            }
    6472        } else {
    6573            // w_min > rmax since w_min > minmax but not (w_min > lmax)
    6674            Assert(w_min > rmax);
    6775            LOGLINE(MATCH, "OR -> AND MAYBE (2)");
    68             ret = new AndMaybePostList(l, r, matcher, dbsize, lhead, rhead);
    69             next_handling_prune(ret, w_min, matcher);
     76            AndMaybePostList * ret2 =
     77                    new AndMaybePostList(l, r, matcher, dbsize, lhead, rhead);
     78            ret = ret2;
     79            if ((lhead <= rhead)) {
     80                next_handling_prune(ret, w_min, matcher);
     81            } else {
     82                handle_prune(ret, ret2->sync_rhs(w_min));
     83            }
    7084        }
    7185
    7286        l = r = NULL;
     
    118132                did = std::max(did, std::max(lhead, rhead));
    119133            } else {
    120134                LOGLINE(MATCH, "OR -> AND MAYBE (in skip_to) (1)");
    121                 ret = new AndMaybePostList(r, l, matcher, dbsize, rhead, lhead);
     135                AndMaybePostList * ret2 =
     136                        new AndMaybePostList(r, l, matcher, dbsize, rhead, lhead);
     137                ret = ret2;
     138                handle_prune(ret, ret2->sync_rhs(w_min));
    122139                did = std::max(did, rhead);
    123140            }
    124141        } else {
    125142            // w_min > rmax since w_min > minmax but not (w_min > lmax)
    126143            Assert(w_min > rmax);
    127144            LOGLINE(MATCH, "OR -> AND MAYBE (in skip_to) (2)");
    128             ret = new AndMaybePostList(l, r, matcher, dbsize, lhead, rhead);
     145            AndMaybePostList * ret2 =
     146                    new AndMaybePostList(l, r, matcher, dbsize, lhead, rhead);
     147            ret = ret2;
     148            handle_prune(ret, ret2->sync_rhs(w_min));
    129149            did = std::max(did, lhead);
    130150        }
    131151
     
    175195                did = std::max(did, std::max(lhead, rhead));
    176196            } else {
    177197                LOGLINE(MATCH, "OR -> AND MAYBE (in check) (1)");
    178                 ret = new AndMaybePostList(r, l, matcher, dbsize, rhead, lhead);
     198                AndMaybePostList * ret2 = new AndMaybePostList(r, l, matcher, dbsize, rhead, lhead);
     199                ret = ret2;
     200                handle_prune(ret, ret2->sync_rhs(w_min));
    179201                did = std::max(did, rhead);
    180202            }
    181203        } else {
     
    183205            Assert(w_min > rmax);
    184206            LOGLINE(MATCH, "OR -> AND MAYBE (in check) (2)");
    185207            ret = new AndMaybePostList(l, r, matcher, dbsize, lhead, rhead);
     208
     209            AndMaybePostList * ret2 = new AndMaybePostList(l, r, matcher, dbsize, lhead, rhead);
     210            ret = ret2;
     211            handle_prune(ret, ret2->sync_rhs(w_min));
    186212            did = std::max(did, lhead);
    187213        }
    188214
  • matcher/andmaybepostlist.cc

     
    5858}
    5959
    6060PostList *
     61AndMaybePostList::sync_rhs(Xapian::weight w_min)
     62{
     63    DEBUGCALL(MATCH, PostList *, "AndMaybePostList::sync_rhs", w_min);
     64    bool valid;
     65    check_handling_prune(r, lhead, w_min - lmax, matcher, valid);
     66    if (r->at_end()) {
     67        PostList *tmp = l;
     68        l = NULL;
     69        RETURN(tmp);
     70    }
     71    if (valid) {
     72        rhead = r->get_docid();
     73    } else {
     74        rhead = 0;
     75    }
     76    RETURN(NULL);
     77}
     78
     79PostList *
    6180AndMaybePostList::next(Xapian::weight w_min)
    6281{
    6382    DEBUGCALL(MATCH, PostList *, "AndMaybePostList::next", w_min);