diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-13 18:38:35 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-11 23:03:17 +0100 |
commit | 6051c1247cde61bcc8e483eb4166e5a297c0ecc6 (patch) | |
tree | df3aba1ef4011f2640b17c8cf7a9b106933231ab /common/fulltextindex.h | |
parent | 8740a007515dcf1b315d69ab5c64fcfd40ec980c (diff) | |
download | sink-6051c1247cde61bcc8e483eb4166e5a297c0ecc6.tar.gz sink-6051c1247cde61bcc8e483eb4166e5a297c0ecc6.zip |
Xapian based fulltext indexing
This cuts into the sync performance by about 40%,
but gives us fast fulltext searching for all local content.
Diffstat (limited to 'common/fulltextindex.h')
-rw-r--r-- | common/fulltextindex.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/common/fulltextindex.h b/common/fulltextindex.h new file mode 100644 index 0000000..e06f29d --- /dev/null +++ b/common/fulltextindex.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include "sink_export.h" | ||
4 | |||
5 | #include <string> | ||
6 | #include <functional> | ||
7 | #include <QString> | ||
8 | #include <memory> | ||
9 | #include "storage.h" | ||
10 | #include "log.h" | ||
11 | |||
12 | namespace Xapian { | ||
13 | class Database; | ||
14 | class WritableDatabase; | ||
15 | }; | ||
16 | |||
17 | class SINK_EXPORT FulltextIndex | ||
18 | { | ||
19 | public: | ||
20 | FulltextIndex(const QByteArray &resourceInstanceIdentifier, Sink::Storage::DataStore::AccessMode mode = Sink::Storage::DataStore::ReadOnly); | ||
21 | ~FulltextIndex(); | ||
22 | |||
23 | void add(const QByteArray &key, const QString &value); | ||
24 | void add(const QByteArray &key, const QList<QPair<QString, QString>> &values); | ||
25 | void remove(const QByteArray &key); | ||
26 | |||
27 | void commitTransaction(); | ||
28 | void abortTransaction(); | ||
29 | |||
30 | QVector<QByteArray> lookup(const QString &key); | ||
31 | |||
32 | private: | ||
33 | Xapian::WritableDatabase* writableDatabase(); | ||
34 | Q_DISABLE_COPY(FulltextIndex); | ||
35 | Xapian::Database *mDb{nullptr}; | ||
36 | QString mName; | ||
37 | QString mDbPath; | ||
38 | bool mHasTransactionOpen{false}; | ||
39 | }; | ||