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.48 2007-06-02 08:30:42 dockes Exp $  (C) 2004 J.F.Dockes */
19
/* @(#$Id: rcldb.h,v 1.49 2007-06-08 16:05:25 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
...
...
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
75
    /* General stuff (valid for query or update) ****************************/
74
    Db();
76
    Db();
75
    ~Db();
77
    ~Db();
76
78
77
    enum OpenMode {DbRO, DbUpd, DbTrunc};
79
    enum OpenMode {DbRO, DbUpd, DbTrunc};
78
    // KEEP_UPDATED is internal use by reOpen() only
80
    // KEEP_UPDATED is internal use by reOpen() only
...
...
81
    bool open(const string &dbdir, const string &stoplistfn, 
83
    bool open(const string &dbdir, const string &stoplistfn, 
82
          OpenMode mode, int qops = QO_NONE);
84
          OpenMode mode, int qops = QO_NONE);
83
    bool close();
85
    bool close();
84
    bool isopen();
86
    bool isopen();
85
87
86
    /** Return total docs in db */
88
    /** Retrieve main database directory */
87
    int  docCnt(); 
89
    string getDbDir();
88
90
91
    /** Get explanation about last error */
92
    string getReason() const {return m_reason;}
89
93
90
    /* Update-related functions */
94
    /** Return list of configured stop words */
95
    const StopList& getStopList() const {return m_stops;}
96
97
98
    /* Update-related methods ******************************************/
91
99
92
    /** Add document. The Doc class should have been filled as much as
100
    /** Add document. The Doc class should have been filled as much as
93
       possible depending on the document type */
101
       possible depending on the document type */
94
    bool add(const string &filename, const Doc &doc, const struct stat *stp);
102
    bool add(const string &filename, const Doc &doc, const struct stat *stp);
95
103
...
...
109
    /** Create stem expansion database for given language. */
117
    /** Create stem expansion database for given language. */
110
    bool createStemDb(const string &lang);
118
    bool createStemDb(const string &lang);
111
    /** Delete stem expansion database for given language. */
119
    /** Delete stem expansion database for given language. */
112
    bool deleteStemDb(const string &lang);
120
    bool deleteStemDb(const string &lang);
113
121
114
    /* Query-related functions */
122
    /** Adjust flush threshold */
123
    void setFlushMb(int mb) {m_flushmb = mb;}
124
125
126
    /* Query-related methods ************************************/
127
128
    /** Return total docs in db */
129
    int  docCnt(); 
115
130
116
    // Parse query string and initialize query
131
    // Parse query string and initialize query
117
    bool setQuery(RefCntr<SearchData> q, int opts = QO_NONE,
132
    bool setQuery(RefCntr<SearchData> q, int opts = QO_NONE,
118
          const string& stemlang = "english");
133
          const string& stemlang = "english");
119
    bool getQueryTerms(list<string>& terms);
134
    bool getQueryTerms(list<string>& terms);
...
...
153
    /** Get results count for current query */
168
    /** Get results count for current query */
154
    int getResCnt();
169
    int getResCnt();
155
170
156
    /** Get a list of existing stemming databases */
171
    /** Get a list of existing stemming databases */
157
    std::list<std::string> getStemLangs();
172
    std::list<std::string> getStemLangs();
158
159
    /** Retrieve main database directory */
160
    string getDbDir();
161
173
162
    /** Set parameters for synthetic abstract generation */
174
    /** Set parameters for synthetic abstract generation */
163
    void setAbstractParams(int idxTrunc, int synthLen, int syntCtxLen);
175
    void setAbstractParams(int idxTrunc, int synthLen, int syntCtxLen);
164
176
165
    /** Whole term list walking. */
177
    /** Whole term list walking. */
...
...
172
    bool stemDiffers(const string& lang, const string& term, 
184
    bool stemDiffers(const string& lang, const string& term, 
173
             const string& base);
185
             const string& base);
174
    
186
    
175
    /** Filename wildcard expansion */
187
    /** Filename wildcard expansion */
176
    bool filenameWildExp(const string& exp, list<string>& names);
188
    bool filenameWildExp(const string& exp, list<string>& names);
177
    string getReason() const {return m_reason;}
178
179
    /** Adjust flush threshold */
180
    void setFlushMb(int mb) {m_flushmb = mb;}
181
182
    const StopList& getStopList() const {return m_stops;}
183
189
184
private:
190
private:
185
191
186
    string m_filterTopDir; // Current query filter on subtree top directory 
192
    string m_filterTopDir; // Current query filter on subtree top directory 
187
    vector<int> m_dbindices; // In case there is a postq filter: sequence of 
193
    vector<int> m_dbindices; // In case there is a postq filter: sequence of 
188
                             // db indices that match
194
                             // db indices that match
189
195
190
    string m_reason; // Error explanation
196
    string m_reason; // Error explanation
197
191
    // Things we don't want to have here.
198
    // A place for things we don't want visible here.
192
    friend class Native;
199
    friend class Native;
193
    Native *m_ndb; // Pointer to private data. We don't want db(ie
200
    Native *m_ndb; 
194
                 // xapian)-specific defs to show in here
195
201
196
    unsigned int m_qOpts;
202
    unsigned int m_qOpts;
197
    
203
    
198
    // This is how long an abstract we keep or build from beginning of
204
    // This is how long an abstract we keep or build from beginning of
199
    // text when indexing. It only has an influence on the size of the
205
    // text when indexing. It only has an influence on the size of the