Switch to unified view

a/src/rcldb/rcldb_p.h b/src/rcldb/rcldb_p.h
...
...
34
namespace Rcl {
34
namespace Rcl {
35
35
36
class Query;
36
class Query;
37
37
38
#ifdef IDX_THREADS
38
#ifdef IDX_THREADS
39
// Task for the index update thread. This can be either and add/update
39
// Task for the index update thread. This can be 
40
// or a purge op, in which case the txtlen is (size_t)-1
40
//  - add/update for a new / update documment
41
//  - delete for a deleted document
42
//  - purgeOrphans when a multidoc file is updated during a partial pass (no 
43
//    general purge). We want to remove subDocs that possibly don't
44
//    exist anymore. We find them by their different sig
45
// txtlen and doc are only valid for add/update else, len is (size_t)-1 and doc
46
// is empty
41
class DbUpdTask {
47
class DbUpdTask {
42
public:
48
public:
49
    enum Op {AddOrUpdate, Delete, PurgeOrphans};
50
    // Note that udi and uniterm are strictly equivalent and are
51
    // passed both just to avoid recomputing uniterm which is
52
    // available on the caller site.
43
    DbUpdTask(const string& ud, const string& un, const Xapian::Document &d,
53
    DbUpdTask(Op _op, const string& ud, const string& un, 
44
  size_t tl)
54
        const Xapian::Document &d, size_t tl)
45
    : udi(ud), uniterm(un), doc(d), txtlen(tl)
55
    : op(_op), udi(ud), uniterm(un), doc(d), txtlen(tl)
46
    {}
56
    {}
57
    // Udi and uniterm equivalently designate the doc
58
    Op op;
47
    string udi;
59
    string udi;
48
    string uniterm;
60
    string uniterm;
49
    Xapian::Document doc;
61
    Xapian::Document doc;
62
    // txtlen is used to update the flush interval. It's -1 for a
63
    // purge because we actually don't know it, and the code fakes a
64
    // text length based on the term count.
50
    size_t txtlen;
65
    size_t txtlen;
51
};
66
};
52
#endif // IDX_THREADS
67
#endif // IDX_THREADS
53
68
54
// A class for data and methods that would have to expose
69
// A class for data and methods that would have to expose
...
...
84
99
85
    // Final steps of doc update, part which need to be single-threaded
100
    // Final steps of doc update, part which need to be single-threaded
86
    bool addOrUpdateWrite(const string& udi, const string& uniterm, 
101
    bool addOrUpdateWrite(const string& udi, const string& uniterm, 
87
              Xapian::Document& doc, size_t txtlen);
102
              Xapian::Document& doc, size_t txtlen);
88
103
104
    bool purgeFileWrite(bool onlyOrphans, const string& udi, 
105
          const string& uniterm);
89
    bool getPagePositions(Xapian::docid docid, vector<int>& vpos);
106
    bool getPagePositions(Xapian::docid docid, vector<int>& vpos);
90
    int getPageNumberForPosition(const vector<int>& pbreaks, unsigned int pos);
107
    int getPageNumberForPosition(const vector<int>& pbreaks, unsigned int pos);
91
108
92
    bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc);
109
    bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc);
93
110