Switch to unified view

a/src/rcldb/rcldb.h b/src/rcldb/rcldb.h
...
...
14
 *   Free Software Foundation, Inc.,
14
 *   Free Software Foundation, Inc.,
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
16
 */
17
#ifndef _DB_H_INCLUDED_
17
#ifndef _DB_H_INCLUDED_
18
#define _DB_H_INCLUDED_
18
#define _DB_H_INCLUDED_
19
/* @(#$Id: rcldb.h,v 1.54 2007-07-10 09:23:28 dockes Exp $  (C) 2004 J.F.Dockes */
19
/* @(#$Id: rcldb.h,v 1.55 2008-06-13 18:22:46 dockes Exp $  (C) 2004 J.F.Dockes */
20
20
21
#include <string>
21
#include <string>
22
#include <list>
22
#include <list>
23
#include <vector>
23
#include <vector>
24
24
...
...
50
#ifndef NO_NAMESPACES
50
#ifndef NO_NAMESPACES
51
namespace Rcl {
51
namespace Rcl {
52
#endif
52
#endif
53
53
54
class SearchData;
54
class SearchData;
55
class Native;
56
class TermIter;
55
class TermIter;
56
class Query;
57
57
58
class TermMatchEntry {
58
class TermMatchEntry {
59
public:
59
public:
60
    TermMatchEntry() : wcf(0) {}
60
    TermMatchEntry() : wcf(0) {}
61
    TermMatchEntry(const string&t, int f) : term(t), wcf(f) {}
61
    TermMatchEntry(const string&t, int f) : term(t), wcf(f) {}
...
...
69
/**
69
/**
70
 * Wrapper class for the native database.
70
 * Wrapper class for the native database.
71
 */
71
 */
72
class Db {
72
class Db {
73
 public:
73
 public:
74
    // A place for things we don't want visible here.
75
    class Native;
76
    friend class Native;
74
77
75
    /* General stuff (valid for query or update) ****************************/
78
    /* General stuff (valid for query or update) ****************************/
76
    Db();
79
    Db();
77
    ~Db();
80
    ~Db();
78
81
79
    enum OpenMode {DbRO, DbUpd, DbTrunc};
82
    enum OpenMode {DbRO, DbUpd, DbTrunc};
80
    // KEEP_UPDATED is internal use by reOpen() only
81
    enum QueryOpts {QO_NONE=0, QO_STEM = 1, QO_KEEP_UPDATED = 8};
82
83
    bool open(const string &dbdir, const string &stoplistfn, 
83
    bool open(const string &dbdir, const string &stoplistfn, 
84
        OpenMode mode, int qops = QO_NONE);
84
        OpenMode mode, bool keep_updated = false);
85
    bool close();
85
    bool close();
86
    bool isopen();
86
    bool isopen();
87
87
88
    /** Retrieve main database directory */
88
    /** Retrieve main database directory */
89
    string getDbDir();
89
    string getDbDir();
...
...
128
    /* Query-related methods ************************************/
128
    /* Query-related methods ************************************/
129
129
130
    /** Return total docs in db */
130
    /** Return total docs in db */
131
    int  docCnt(); 
131
    int  docCnt(); 
132
132
133
    // Parse query string and initialize query
133
    /** Add extra database for querying */
134
    bool setQuery(RefCntr<SearchData> q, int opts = QO_NONE,
134
    bool addQueryDb(const string &dir);
135
        const string& stemlang = "english");
135
    /** Remove extra database. if dir == "", remove all. */
136
    bool getQueryTerms(list<string>& terms);
136
    bool rmQueryDb(const string &dir);
137
    bool getMatchTerms(const Doc& doc, list<string>& terms);
137
    /** Tell if directory seems to hold xapian db */
138
    static bool testDbDir(const string &dir);
138
139
139
    /** Return a list of index terms that match the input string
140
    /** Return a list of index terms that match the input string
140
     * Expansion is performed either with either wildcard or regexp processing
141
     * Expansion is performed either with either wildcard or regexp processing
141
     * Stem expansion is performed if lang is not empty */
142
     * Stem expansion is performed if lang is not empty */
142
    enum MatchType {ET_WILD, ET_REGEXP, ET_STEM};
143
    enum MatchType {ET_WILD, ET_REGEXP, ET_STEM};
143
    bool termMatch(MatchType typ, const string &lang, const string &s, 
144
    bool termMatch(MatchType typ, const string &lang, const string &s, 
144
           list<TermMatchEntry>& result, int max = -1);
145
           list<TermMatchEntry>& result, int max = -1);
145
146
146
    /** Add extra database for querying */
147
    bool addQueryDb(const string &dir);
148
    /** Remove extra database. if dir == "", remove all. */
149
    bool rmQueryDb(const string &dir);
150
    /** Tell if directory seems to hold xapian db */
151
    static bool testDbDir(const string &dir);
152
153
    /** Get document at rank i in current query. 
154
155
  This is probably vastly inferior to the type of interface in
156
  Xapian, but we have to start with something simple to
157
  experiment with the GUI. i is sequential from 0 to some value.
158
    */
159
    bool getDoc(int i, Doc &doc, int *percent = 0);
160
161
    /* Build synthetic abstract out of query terms and term position data */
147
    /* Build synthetic abstract out of query terms and term position data */
162
    bool makeDocAbstract(Doc &doc, string& abstract);
148
    bool makeDocAbstract(Doc &doc, Query *query, string& abstract);
163
149
164
    /** Get document for given filename and ipath */
150
    /** Get document for given filename and ipath */
165
    bool getDoc(const string &fn, const string &ipath, Doc &doc, int *percent);
151
    bool getDoc(const string &fn, const string &ipath, Doc &doc, int *percent);
166
167
    /** Expand query */
168
    list<string> expand(const Doc &doc);
169
170
    /** Get results count for current query */
171
    int getResCnt();
172
152
173
    /** Get a list of existing stemming databases */
153
    /** Get a list of existing stemming databases */
174
    std::list<std::string> getStemLangs();
154
    std::list<std::string> getStemLangs();
175
155
176
    /** Set parameters for synthetic abstract generation */
156
    /** Set parameters for synthetic abstract generation */
...
...
187
             const string& base);
167
             const string& base);
188
    
168
    
189
    /** Filename wildcard expansion */
169
    /** Filename wildcard expansion */
190
    bool filenameWildExp(const string& exp, list<string>& names);
170
    bool filenameWildExp(const string& exp, list<string>& names);
191
171
172
    /** This has to be public for access by embedded Query::Native */
173
    Native *m_ndb; 
174
192
private:
175
private:
193
    // Internal form of close, can be called during destruction
176
    // Internal form of close, can be called during destruction
194
    bool i_close(bool final);
177
    bool i_close(bool final);
195
178
196
    string m_filterTopDir; // Current query filter on subtree top directory 
197
    vector<int> m_dbindices; // In case there is a postq filter: sequence of 
198
                             // db indices that match
199
200
    string m_reason; // Error explanation
179
    string m_reason; // Error explanation
201
180
202
    // A place for things we don't want visible here.
181
    /* Parameters cached out of the configuration files */
203
    friend class Native;
204
    Native *m_ndb; 
205
206
    unsigned int m_qOpts;
207
    
208
    // This is how long an abstract we keep or build from beginning of
182
    // This is how long an abstract we keep or build from beginning of
209
    // text when indexing. It only has an influence on the size of the
183
    // text when indexing. It only has an influence on the size of the
210
    // db as we are free to shorten it again when displaying
184
    // db as we are free to shorten it again when displaying
211
    int          m_idxAbsTruncLen;
185
    int          m_idxAbsTruncLen;
212
    // This is the size of the abstract that we synthetize out of query
186
    // This is the size of the abstract that we synthetize out of query
213
    // term contexts at *query time*
187
    // term contexts at *query time*
214
    int          m_synthAbsLen;
188
    int          m_synthAbsLen;
215
    // This is how many words (context size) we keep around query terms
189
    // This is how many words (context size) we keep around query terms
216
    // when building the abstract
190
    // when building the abstract
217
    int          m_synthAbsWordCtxLen;
191
    int          m_synthAbsWordCtxLen;
218
219
    // Flush threshold. Megabytes of text indexed before we flush.
192
    // Flush threshold. Megabytes of text indexed before we flush.
220
    int          m_flushMb;
193
    int          m_flushMb;
221
    // Text bytes indexed since beginning
194
    // Text bytes indexed since beginning
222
    long long    m_curtxtsz;
195
    long long    m_curtxtsz;
223
    // Text bytes at last flush
196
    // Text bytes at last flush
224
    long long    m_flushtxtsz;
197
    long long    m_flushtxtsz;
225
    // Text bytes at last fsoccup check
198
    // Text bytes at last fsoccup check
226
    long long    m_occtxtsz;
199
    long long    m_occtxtsz;
227
228
    // Maximum file system occupation percentage
200
    // Maximum file system occupation percentage
229
    int          m_maxFsOccupPc;
201
    int          m_maxFsOccupPc;
230
202
231
    // Database directory
203
    // Database directory
232
    string       m_basedir;
204
    string       m_basedir;