8#include "documenttimedb.h"
9#include "enginedebug.h"
13DocumentTimeDB::DocumentTimeDB(MDB_dbi dbi, MDB_txn* txn)
17 Q_ASSERT(txn !=
nullptr);
21DocumentTimeDB::~DocumentTimeDB()
25MDB_dbi DocumentTimeDB::create(MDB_txn* txn)
28 int rc = mdb_dbi_open(txn,
"documenttimedb", MDB_CREATE | MDB_INTEGERKEY, &dbi);
30 qCWarning(ENGINE) <<
"DocumentTimeDB::create" << mdb_strerror(rc);
37MDB_dbi DocumentTimeDB::open(MDB_txn* txn)
40 int rc = mdb_dbi_open(txn,
"documenttimedb", MDB_INTEGERKEY, &dbi);
42 qCWarning(ENGINE) <<
"DocumentTimeDB::open" << mdb_strerror(rc);
49void DocumentTimeDB::put(quint64 docId,
const TimeInfo& info)
54 key.mv_size =
sizeof(quint64);
58 val.mv_size =
sizeof(TimeInfo);
59 val.mv_data =
static_cast<void*
>(
const_cast<TimeInfo*
>(&info));
61 int rc = mdb_put(m_txn, m_dbi, &key, &val, 0);
63 qCWarning(ENGINE) <<
"DocumentTimeDB::put" << docId << mdb_strerror(rc);
67DocumentTimeDB::TimeInfo DocumentTimeDB::get(quint64 docId)
72 key.mv_size =
sizeof(quint64);
75 MDB_val val{0,
nullptr};
76 int rc = mdb_get(m_txn, m_dbi, &key, &val);
78 if (rc != MDB_NOTFOUND) {
79 qCDebug(ENGINE) <<
"DocumentTimeDB::get" << docId << mdb_strerror(rc);
84 return *(
static_cast<TimeInfo*
>(val.mv_data));
87void DocumentTimeDB::del(quint64 docId)
92 key.mv_size =
sizeof(quint64);
93 key.mv_data =
static_cast<void*
>(&docId);
95 int rc = mdb_del(m_txn, m_dbi, &key,
nullptr);
96 if (rc != 0 && rc != MDB_NOTFOUND) {
97 qCDebug(ENGINE) <<
"DocumentTimeDB::del" << docId << mdb_strerror(rc);
101bool DocumentTimeDB::contains(quint64 docId)
106 key.mv_size =
sizeof(quint64);
107 key.mv_data =
static_cast<void*
>(&docId);
110 int rc = mdb_get(m_txn, m_dbi, &key, &val);
112 if (rc != MDB_NOTFOUND) {
113 qCDebug(ENGINE) <<
"DocumentTimeDB::contains" << docId << mdb_strerror(rc);
124 mdb_cursor_open(m_txn, m_dbi, &cursor);
126 MDB_val key = {0,
nullptr};
131 int rc = mdb_cursor_get(cursor, &key, &val, MDB_NEXT);
133 qCDebug(ENGINE) <<
"DocumentTimeDB::toTestMap" << mdb_strerror(rc);
137 const quint64
id = *(
static_cast<quint64*
>(key.mv_data));
138 const TimeInfo ti = *(
static_cast<TimeInfo*
>(val.mv_data));
142 mdb_cursor_close(cursor);
Implements storage for docIds without any associated data Instantiated for:
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)