Ticket #59: xapian-faster-flint-add-document.patch

File xapian-faster-flint-add-document.patch, 5.7 KB (added by Olly Betts, 9 years ago)

Externally hosted patch refererred to in an earlier comment

  • backends/flint/flint_database.h

     
    224224        mutable map<Xapian::docid, Xapian::termcount> doclens;
    225225
    226226        /// Modifications to posting lists.
    227         mutable map<string, map<Xapian::docid,
    228                                 pair<char, Xapian::termcount> > > mod_plists;
     227        mutable map<string, vector<pair<Xapian::docid, Xapian::termcount> > > mod_plists;
    229228
    230229        /** The readonly database encapsulated in the writable database.
    231230         */
  • backends/flint/flint_database.cc

     
    623623                }
    624624
    625625                // Add did to tname's postlist
    626                 map<string, map<docid, pair<char, termcount> > >::iterator j;
     626                map<string, vector<pair<docid, termcount> > >::iterator j;
    627627                j = mod_plists.find(tname);
    628628                if (j == mod_plists.end()) {
    629                     map<docid, pair<char, termcount> > m;
     629                    vector<pair<docid, termcount> > m;
    630630                    j = mod_plists.insert(make_pair(tname, m)).first;
    631631                }
    632                 Assert(j->second.find(did) == j->second.end());
    633                 j->second.insert(make_pair(did, make_pair('A', wdf)));
     632                j->second.push_back(make_pair(did, wdf));
    634633
    635634                if (term.positionlist_begin() != term.positionlist_end()) {
    636635                    database_ro.positionlist_table.set_positionlist(
     
    679678    DEBUGCALL(DB, void, "FlintWritableDatabase::delete_document", did);
    680679    Assert(did != 0);
    681680
     681    did = did;
     682    throw Xapian::UnimplementedError("delete_document not supported by this experimental patch");
     683#if 0
    682684    try {
    683685        // Remove the record.
    684686        database_ro.record_table.delete_record(did);
     
    742744
    743745    if (++changes_made >= flush_threshold && !transaction_active())
    744746        do_flush_const();
     747#endif
    745748}
    746749
    747750void
     
    751754    DEBUGCALL(DB, void, "FlintWritableDatabase::replace_document", did << ", " << document);
    752755    Assert(did != 0);
    753756
     757    did = did;
     758    (void)document;
     759    throw Xapian::UnimplementedError("replace_document not supported by this experimental patch");
     760#if 0
    754761    try {
    755762        if (did > lastdocid) {
    756763            lastdocid = did;
     
    896903
    897904    if (++changes_made >= flush_threshold && !transaction_active())
    898905        do_flush_const();
     906#endif
    899907}
    900908
    901909Xapian::doccount
     
    981989                                        get_doccount()));
    982990    }
    983991
    984     map<string, map<docid, pair<char, termcount> > >::const_iterator j;
     992    map<string, vector<pair<docid, termcount> > >::const_iterator j;
    985993    j = mod_plists.find(tname);
    986994    if (j != mod_plists.end()) {
    987995        // We've got buffered changes to this term's postlist, so we need to
    988996        // use a FlintModifiedPostList.
     997        throw Xapian::UnimplementedError("do_open_post_list of a modified term not supported by this experimental patch");
     998#if 0
    989999        RETURN(new FlintModifiedPostList(ptrtothis,
    9901000                                 &database_ro.postlist_table,
    9911001                                 &database_ro.positionlist_table,
    9921002                                 tname,
    9931003                                 j->second));
     1004#endif
    9941005    }
    9951006
    9961007    RETURN(new FlintPostList(ptrtothis,
  • backends/flint/flint_postlist.cc

     
    10511051
    10521052void
    10531053FlintPostListTable::merge_changes(
    1054     const map<string, map<Xapian::docid, pair<char, Xapian::termcount> > > & mod_plists,
     1054    const map<string, vector<pair<Xapian::docid, Xapian::termcount> > > & mod_plists,
    10551055    const map<Xapian::docid, Xapian::termcount> & doclens,
    10561056    const map<string, pair<Xapian::termcount_diff, Xapian::termcount_diff> > & freq_deltas)
    10571057{
    1058     map<string, map<Xapian::docid, pair<char, Xapian::termcount> > >::const_iterator i;
     1058    map<string, vector<pair<Xapian::docid, Xapian::termcount> > >::const_iterator i;
    10591059    for (i = mod_plists.begin(); i != mod_plists.end(); ++i) {
    10601060        if (i->second.empty()) continue;
    10611061        string tname = i->first;
     
    11201120                add(current_key, tag);
    11211121            }
    11221122        }
    1123         map<Xapian::docid, pair<char, Xapian::termcount> >::const_iterator j;
     1123        vector<pair<Xapian::docid, Xapian::termcount> >::const_iterator j;
    11241124        j = i->second.begin();
    11251125        Assert(j != i->second.end()); // This case is caught above.
    11261126
    11271127        Xapian::docid max_did;
    11281128        PostlistChunkReader *from;
    11291129        PostlistChunkWriter *to;
    1130         max_did = get_chunk(tname, j->first, j->second.first == 'A',
     1130        max_did = get_chunk(tname, j->first, true,
    11311131                            &from, &to);
    11321132        for ( ; j != i->second.end(); ++j) {
    11331133            Xapian::docid did = j->first;
     
    11371137                Xapian::docid copy_did = from->get_docid();
    11381138                if (copy_did >= did) {
    11391139                    if (copy_did == did) {
    1140                         Assert(j->second.first != 'A');
     1140                        Assert(false);
    11411141                        from->next();
    11421142                    }
    11431143                    break;
     
    11541154                goto next_chunk;
    11551155            }
    11561156
    1157             if (j->second.first != 'D') {
     1157            if (true) {
    11581158                map<Xapian::docid, Xapian::termcount>::const_iterator k = doclens.find(did);
    11591159                Assert(k != doclens.end());
    11601160                Xapian::termcount new_doclen = k->second;
    1161                 Xapian::termcount new_wdf = j->second.second;
     1161                Xapian::termcount new_wdf = j->second;
    11621162
    11631163                to->append(this, did, new_wdf, new_doclen);
    11641164            }
  • backends/flint/flint_postlist.h

     
    6363
    6464        /// Merge added, removed, and changed entries.
    6565        void merge_changes(
    66             const map<string, map<Xapian::docid, pair<char, Xapian::termcount> > > & mod_plists,
     66            const map<string, vector<pair<Xapian::docid, Xapian::termcount> > > & mod_plists,
    6767            const map<Xapian::docid, Xapian::termcount> & doclens,
    6868            const map<string, pair<Xapian::termcount_diff, Xapian::termcount_diff> > & freq_deltas);
    6969