| 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_IDTREEDB_H |
| 9 | #define BALOO_IDTREEDB_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 | class BALOO_ENGINE_EXPORT IdTreeDB |
| 21 | { |
| 22 | public: |
| 23 | IdTreeDB(MDB_dbi dbi, MDB_txn* txn); |
| 24 | |
| 25 | static MDB_dbi create(MDB_txn* txn); |
| 26 | static MDB_dbi open(MDB_txn* txn); |
| 27 | |
| 28 | void set(quint64 docId, const QVector<quint64> &subDocIds); |
| 29 | QVector<quint64> get(quint64 docId); |
| 30 | |
| 31 | /** |
| 32 | * Returns an iterator which will return all the docIds which use \p docId |
| 33 | * are the parent docID. |
| 34 | */ |
| 35 | PostingIterator* iter(quint64 docId); |
| 36 | |
| 37 | QMap<quint64, QVector<quint64>> toTestMap() const; |
| 38 | private: |
| 39 | MDB_txn* m_txn; |
| 40 | MDB_dbi m_dbi; |
| 41 | }; |
| 42 | } |
| 43 | |
| 44 | #endif // BALOO_IDTREEDB_H |
| 45 | |