a/src/rcldb/rcldb_p.h b/src/rcldb/rcldb_p.h
...
...
16
 */
16
 */
17
17
18
#ifndef _rcldb_p_h_included_
18
#ifndef _rcldb_p_h_included_
19
#define _rcldb_p_h_included_
19
#define _rcldb_p_h_included_
20
20
21
#ifdef IDX_THREADS
22
#include "workqueue.h"
23
#endif // IDX_THREADS
21
#include "xapian.h"
24
#include "xapian.h"
22
25
23
namespace Rcl {
26
namespace Rcl {
24
27
25
// Omega compatible values. We leave a hole for future omega values. Not sure 
28
// Omega compatible values. We leave a hole for future omega values. Not sure 
...
...
61
        break;                                             \
64
        break;                                             \
62
    }
65
    }
63
66
64
class Query;
67
class Query;
65
68
69
#ifdef IDX_THREADS
70
class DbUpdTask {
71
public:
72
    DbUpdTask(const string& ud, const string& un, const Xapian::Document &d,
73
  size_t tl)
74
  : udi(ud), uniterm(un), doc(d), txtlen(tl)
75
    {}
76
    string udi;
77
    string uniterm;
78
    Xapian::Document doc;
79
    size_t txtlen;
80
};
81
#endif // IDX_THREADS
82
66
// A class for data and methods that would have to expose
83
// A class for data and methods that would have to expose
67
// Xapian-specific stuff if they were in Rcl::Db. There could actually be
84
// Xapian-specific stuff if they were in Rcl::Db. There could actually be
68
// 2 different ones for indexing or query as there is not much in
85
// 2 different ones for indexing or query as there is not much in
69
// common.
86
// common.
70
class Db::Native {
87
class Db::Native {
71
 public:
88
 public:
72
    Db  *m_rcldb; // Parent
89
    Db  *m_rcldb; // Parent
73
    bool m_isopen;
90
    bool m_isopen;
74
    bool m_iswritable;
91
    bool m_iswritable;
75
    bool m_noversionwrite; //Set if open failed because of version mismatch!
92
    bool m_noversionwrite; //Set if open failed because of version mismatch!
93
#ifdef IDX_THREADS
94
    WorkQueue<DbUpdTask*> m_wqueue;
95
#endif // IDX_THREADS
76
96
77
    // Indexing 
97
    // Indexing 
78
    Xapian::WritableDatabase xwdb;
98
    Xapian::WritableDatabase xwdb;
79
    // Querying (active even if the wdb is too)
99
    // Querying (active even if the wdb is too)
80
    Xapian::Database xrdb;
100
    Xapian::Database xrdb;
...
...
84
    Xapian::Database& xdb() {return m_iswritable ? xwdb : xrdb;}
104
    Xapian::Database& xdb() {return m_iswritable ? xwdb : xrdb;}
85
105
86
    Native(Db *db) 
106
    Native(Db *db) 
87
    : m_rcldb(db), m_isopen(false), m_iswritable(false),
107
    : m_rcldb(db), m_isopen(false), m_iswritable(false),
88
          m_noversionwrite(false)
108
          m_noversionwrite(false)
109
#ifdef IDX_THREADS
110
  , m_wqueue(10)
111
#endif // IDX_THREADS
89
    { }
112
    { }
90
113
91
    ~Native() {
114
    ~Native() { 
115
#ifdef IDX_THREADS
116
  if (m_iswritable) {
117
      void *status = m_wqueue.setTerminateAndWait();
118
      LOGDEB(("Native: worker status %ld\n", long(status)));
119
  }
120
#endif // IDX_THREADS
92
    }
121
    }
93
122
94
    vector<string> makeAbstract(Xapian::docid id, Query *query);
123
    vector<string> makeAbstract(Xapian::docid id, Query *query);
95
124
96
    bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc);
125
    bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc);