|
a/src/rcldb/rcldb.cpp |
|
b/src/rcldb/rcldb.cpp |
|
... |
|
... |
50 |
#include "rclquery.h"
|
50 |
#include "rclquery.h"
|
51 |
#include "rclquery_p.h"
|
51 |
#include "rclquery_p.h"
|
52 |
#include "md5ut.h"
|
52 |
#include "md5ut.h"
|
53 |
#include "rclversion.h"
|
53 |
#include "rclversion.h"
|
54 |
#include "cancelcheck.h"
|
54 |
#include "cancelcheck.h"
|
55 |
#include "ptmutex.h"
|
|
|
56 |
#include "termproc.h"
|
55 |
#include "termproc.h"
|
57 |
#include "expansiondbs.h"
|
56 |
#include "expansiondbs.h"
|
58 |
#include "rclinit.h"
|
57 |
#include "rclinit.h"
|
59 |
#include "internfile.h"
|
58 |
#include "internfile.h"
|
60 |
|
59 |
|
|
... |
|
... |
569 |
Xapian::Document *newdocument_ptr,
|
568 |
Xapian::Document *newdocument_ptr,
|
570 |
size_t textlen)
|
569 |
size_t textlen)
|
571 |
{
|
570 |
{
|
572 |
#ifdef IDX_THREADS
|
571 |
#ifdef IDX_THREADS
|
573 |
Chrono chron;
|
572 |
Chrono chron;
|
574 |
PTMutexLocker lock(m_mutex);
|
573 |
std::unique_lock<std::mutex> lock(m_mutex);
|
575 |
#endif
|
574 |
#endif
|
576 |
STD_SHARED_PTR<Xapian::Document> doc_cleaner(newdocument_ptr);
|
575 |
STD_SHARED_PTR<Xapian::Document> doc_cleaner(newdocument_ptr);
|
577 |
|
576 |
|
578 |
// Check file system full every mbyte of indexed text. It's a bit wasteful
|
577 |
// Check file system full every mbyte of indexed text. It's a bit wasteful
|
579 |
// to do this after having prepared the document, but it needs to be in
|
578 |
// to do this after having prepared the document, but it needs to be in
|
|
... |
|
... |
638 |
#if defined(IDX_THREADS)
|
637 |
#if defined(IDX_THREADS)
|
639 |
// We need a mutex even if we have a write queue (so we can only
|
638 |
// We need a mutex even if we have a write queue (so we can only
|
640 |
// be called by a single thread) to protect about multiple acces
|
639 |
// be called by a single thread) to protect about multiple acces
|
641 |
// to xrdb from subDocs() which is also called from needupdate()
|
640 |
// to xrdb from subDocs() which is also called from needupdate()
|
642 |
// (called from outside the write thread !
|
641 |
// (called from outside the write thread !
|
643 |
PTMutexLocker lock(m_mutex);
|
642 |
std::unique_lock<std::mutex> lock(m_mutex);
|
644 |
#endif // IDX_THREADS
|
643 |
#endif // IDX_THREADS
|
645 |
|
644 |
|
646 |
string ermsg;
|
645 |
string ermsg;
|
647 |
try {
|
646 |
try {
|
648 |
Xapian::PostingIterator docid = xwdb.postlist_begin(uniterm);
|
647 |
Xapian::PostingIterator docid = xwdb.postlist_begin(uniterm);
|
|
... |
|
... |
1584 |
bool Db::Native::docToXdocXattrOnly(TextSplitDb *splitter, const string &udi,
|
1583 |
bool Db::Native::docToXdocXattrOnly(TextSplitDb *splitter, const string &udi,
|
1585 |
Doc &doc, Xapian::Document& xdoc)
|
1584 |
Doc &doc, Xapian::Document& xdoc)
|
1586 |
{
|
1585 |
{
|
1587 |
LOGDEB0("Db::docToXdocXattrOnly\n" );
|
1586 |
LOGDEB0("Db::docToXdocXattrOnly\n" );
|
1588 |
#ifdef IDX_THREADS
|
1587 |
#ifdef IDX_THREADS
|
1589 |
PTMutexLocker lock(m_mutex);
|
1588 |
std::unique_lock<std::mutex> lock(m_mutex);
|
1590 |
#endif
|
1589 |
#endif
|
1591 |
|
1590 |
|
1592 |
// Read existing document and its data record
|
1591 |
// Read existing document and its data record
|
1593 |
if (getDoc(udi, 0, xdoc) == 0) {
|
1592 |
if (getDoc(udi, 0, xdoc) == 0) {
|
1594 |
LOGERR("docToXdocXattrOnly: existing doc not found\n" );
|
1593 |
LOGERR("docToXdocXattrOnly: existing doc not found\n" );
|
|
... |
|
... |
1712 |
if (docid == (unsigned int)-1) {
|
1711 |
if (docid == (unsigned int)-1) {
|
1713 |
LOGERR("Db::setExistingFlags: called with bogus docid !!\n" );
|
1712 |
LOGERR("Db::setExistingFlags: called with bogus docid !!\n" );
|
1714 |
return;
|
1713 |
return;
|
1715 |
}
|
1714 |
}
|
1716 |
#ifdef IDX_THREADS
|
1715 |
#ifdef IDX_THREADS
|
1717 |
PTMutexLocker lock(m_ndb->m_mutex);
|
1716 |
std::unique_lock<std::mutex> lock(m_ndb->m_mutex);
|
1718 |
#endif
|
1717 |
#endif
|
1719 |
i_setExistingFlags(udi, docid);
|
1718 |
i_setExistingFlags(udi, docid);
|
1720 |
}
|
1719 |
}
|
1721 |
|
1720 |
|
1722 |
void Db::i_setExistingFlags(const string& udi, unsigned int docid)
|
1721 |
void Db::i_setExistingFlags(const string& udi, unsigned int docid)
|
|
... |
|
... |
1772 |
#ifdef IDX_THREADS
|
1771 |
#ifdef IDX_THREADS
|
1773 |
// Need to protect against interaction with the doc update/insert
|
1772 |
// Need to protect against interaction with the doc update/insert
|
1774 |
// thread which also updates the existence map, and even multiple
|
1773 |
// thread which also updates the existence map, and even multiple
|
1775 |
// accesses to the readonly Xapian::Database are not allowed
|
1774 |
// accesses to the readonly Xapian::Database are not allowed
|
1776 |
// anyway
|
1775 |
// anyway
|
1777 |
PTMutexLocker lock(m_ndb->m_mutex);
|
1776 |
std::unique_lock<std::mutex> lock(m_ndb->m_mutex);
|
1778 |
#endif
|
1777 |
#endif
|
1779 |
|
1778 |
|
1780 |
// Try to find the document indexed by the uniterm.
|
1779 |
// Try to find the document indexed by the uniterm.
|
1781 |
Xapian::PostingIterator docid;
|
1780 |
Xapian::PostingIterator docid;
|
1782 |
XAPTRY(docid = m_ndb->xrdb.postlist_begin(uniterm), m_ndb->xrdb, m_reason);
|
1781 |
XAPTRY(docid = m_ndb->xrdb.postlist_begin(uniterm), m_ndb->xrdb, m_reason);
|
|
... |
|
... |
1888 |
if (m_ndb->m_havewriteq)
|
1887 |
if (m_ndb->m_havewriteq)
|
1889 |
m_ndb->m_wqueue.setTerminateAndWait();
|
1888 |
m_ndb->m_wqueue.setTerminateAndWait();
|
1890 |
// else we need to lock out other top level threads. This is just
|
1889 |
// else we need to lock out other top level threads. This is just
|
1891 |
// a precaution as they should have been waited for by the top
|
1890 |
// a precaution as they should have been waited for by the top
|
1892 |
// level actor at this point
|
1891 |
// level actor at this point
|
1893 |
PTMutexLocker lock(m_ndb->m_mutex, m_ndb->m_havewriteq);
|
1892 |
std::unique_lock<std::mutex> lock(m_ndb->m_mutex);
|
1894 |
#endif // IDX_THREADS
|
1893 |
#endif // IDX_THREADS
|
1895 |
|
1894 |
|
1896 |
// For xapian versions up to 1.0.1, deleting a non-existant
|
1895 |
// For xapian versions up to 1.0.1, deleting a non-existant
|
1897 |
// document would trigger an exception that would discard any
|
1896 |
// document would trigger an exception that would discard any
|
1898 |
// pending update. This could lose both previous added documents
|
1897 |
// pending update. This could lose both previous added documents
|
|
... |
|
... |
1955 |
// Test for doc existence.
|
1954 |
// Test for doc existence.
|
1956 |
bool Db::docExists(const string& uniterm)
|
1955 |
bool Db::docExists(const string& uniterm)
|
1957 |
{
|
1956 |
{
|
1958 |
#ifdef IDX_THREADS
|
1957 |
#ifdef IDX_THREADS
|
1959 |
// Need to protect read db against multiaccess.
|
1958 |
// Need to protect read db against multiaccess.
|
1960 |
PTMutexLocker lock(m_ndb->m_mutex);
|
1959 |
std::unique_lock<std::mutex> lock(m_ndb->m_mutex);
|
1961 |
#endif
|
1960 |
#endif
|
1962 |
|
1961 |
|
1963 |
string ermsg;
|
1962 |
string ermsg;
|
1964 |
try {
|
1963 |
try {
|
1965 |
Xapian::PostingIterator docid = m_ndb->xrdb.postlist_begin(uniterm);
|
1964 |
Xapian::PostingIterator docid = m_ndb->xrdb.postlist_begin(uniterm);
|