File indexing completed on 2024-04-21 03:51:39
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_DOCUMENTDB_H 0009 #define BALOO_DOCUMENTDB_H 0010 0011 #include "engine_export.h" 0012 #include <lmdb.h> 0013 #include <QVector> 0014 #include <QMap> 0015 0016 namespace Baloo { 0017 0018 /** 0019 * Implements storage for a set of <term>s for the given docId 0020 * Instantiated for: 0021 * - document (content) terms 0022 * - filename terms 0023 * - xattr terms 0024 */ 0025 class BALOO_ENGINE_EXPORT DocumentDB 0026 { 0027 public: 0028 DocumentDB(MDB_dbi dbi, MDB_txn* txn); 0029 ~DocumentDB(); 0030 0031 static MDB_dbi create(const char* name, MDB_txn* txn); 0032 static MDB_dbi open(const char* name, MDB_txn* txn); 0033 0034 void put(quint64 docId, const QVector< QByteArray >& list); 0035 QVector<QByteArray> get(quint64 docId); 0036 0037 bool contains(quint64 docId); 0038 void del(quint64 docId); 0039 uint size(); 0040 0041 QMap<quint64, QVector<QByteArray>> toTestMap() const; 0042 private: 0043 MDB_txn* m_txn; 0044 MDB_dbi m_dbi; 0045 }; 0046 } 0047 0048 #endif // BALOO_DOCUMENTDB_H