File indexing completed on 2024-04-28 11:32:44

0001 /*
0002     This file is part of the KDE Baloo project.
0003     SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 #ifndef BALOO_MTIMEDB_H
0009 #define BALOO_MTIMEDB_H
0010 
0011 #include "engine_export.h"
0012 #include <lmdb.h>
0013 #include <QVector>
0014 #include <QMap>
0015 
0016 namespace Baloo {
0017 
0018 class PostingIterator;
0019 
0020 /**
0021  * The MTime DB maps the file mtime to its id. This allows us to do
0022  * fast searches of files between a certain time range.
0023  */
0024 class BALOO_ENGINE_EXPORT MTimeDB
0025 {
0026 public:
0027     explicit MTimeDB(MDB_dbi dbi, MDB_txn* txn);
0028     ~MTimeDB();
0029 
0030     static MDB_dbi create(MDB_txn* txn);
0031     static MDB_dbi open(MDB_txn* txn);
0032 
0033     void put(quint32 mtime, quint64 docId);
0034     QVector<quint64> get(quint32 mtime);
0035 
0036     void del(quint32 mtime, quint64 docId);
0037 
0038     /**
0039       * Get documents with an mtime between \p beginTime and
0040       * \p endTime (inclusive)
0041       */
0042     PostingIterator* iterRange(quint32 beginTime, quint32 endTime);
0043 
0044     QMap<quint32, quint64> toTestMap() const;
0045 private:
0046     MDB_txn* m_txn;
0047     MDB_dbi m_dbi;
0048 };
0049 }
0050 
0051 #endif // BALOO_MTIMEDB_H