| 1 | /* |
| 2 | This file is part of the KDE Baloo project. |
| 3 | SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef BALOO_MTIMEDB_H |
| 9 | #define BALOO_MTIMEDB_H |
| 10 | |
| 11 | #include "engine_export.h" |
| 12 | #include <lmdb.h> |
| 13 | #include <QVector> |
| 14 | #include <QMap> |
| 15 | |
| 16 | namespace Baloo { |
| 17 | |
| 18 | class PostingIterator; |
| 19 | |
| 20 | /** |
| 21 | * The MTime DB maps the file mtime to its id. This allows us to do |
| 22 | * fast searches of files between a certain time range. |
| 23 | */ |
| 24 | class BALOO_ENGINE_EXPORT MTimeDB |
| 25 | { |
| 26 | public: |
| 27 | explicit MTimeDB(MDB_dbi dbi, MDB_txn* txn); |
| 28 | ~MTimeDB(); |
| 29 | |
| 30 | static MDB_dbi create(MDB_txn* txn); |
| 31 | static MDB_dbi open(MDB_txn* txn); |
| 32 | |
| 33 | void put(quint32 mtime, quint64 docId); |
| 34 | QVector<quint64> get(quint32 mtime); |
| 35 | |
| 36 | void del(quint32 mtime, quint64 docId); |
| 37 | |
| 38 | /** |
| 39 | * Get documents with an mtime between \p beginTime and |
| 40 | * \p endTime (inclusive) |
| 41 | */ |
| 42 | PostingIterator* iterRange(quint32 beginTime, quint32 endTime); |
| 43 | |
| 44 | QMap<quint32, quint64> toTestMap() const; |
| 45 | private: |
| 46 | MDB_txn* m_txn; |
| 47 | MDB_dbi m_dbi; |
| 48 | }; |
| 49 | } |
| 50 | |
| 51 | #endif // BALOO_MTIMEDB_H |
| 52 | |